Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leigh Cepriano Pulzone #441

Open
wants to merge 24 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions day_1/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#puts "Hello World!"
#puts "Hello Again"
#puts "I like typing this."
#puts "This is fun."
puts "Yay! Printing."
#puts "I'd much rather you 'not'."
#puts 'I "said" do not touch this.'
#puts "I am interested in why a double quotation and a single quotation were used."
#puts "This looks messy to me."
12 changes: 12 additions & 0 deletions day_1/ex2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# A comment, this is so you can read your program later.

# Anything after the # is ignored by ruby.


puts "I could have code like this." # and the comment after is ignored


# You can also use a comment to "disable" or comment out a piece of code:
# puts "This won't run."

puts "This will run."
34 changes: 34 additions & 0 deletions day_1/ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# This prints out the line below
puts "I will now count my chickens:"

# This is a math equation, first dividing 30 & 6 then adding 25.
puts "Hens #{25.0 + 30.0 / 6.0}"
# This is a math equation, I'm not quite sure what the whole equation is doing. I'm a little confused about what to do with the remaing 4.
# Added in later: I was able to dive into the % and feel more confident with it.
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"
# This prints out the line below.
puts "Now I will count the eggs:"

# This is a math equation that states the amount of eggs available.
puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0

# This a question posed
puts "Is it true that 3.0 + 2.0 < 5.0 - 7.0?"

# This is the answer to the above stated question
puts 3.0 + 2.0 < 5.0 - 7.0

# These next two lines are indicating the break down of the above equation to find out why it's answered as false
puts "What is 3.0 + 2.0? #{3.0 + 2.0}"
puts "What is 5.0 - 7.0? #{5.0 - 7.0}"

# This prints out the line below
puts "Oh, that's why it's false."

# This prints out the line below
puts "How about some more."

# The next three lines are answering boolean logic, which is why there is a 'true' or 'false' stated instead of the answer to the equation.
puts "Is it greater? #{5.0 > -2.0}"
puts "Is it greater or equal? #{5.0 >= -2.0}"
puts "Is it less or equal? #{5.0 <= -2.0}"
30 changes: 30 additions & 0 deletions day_1/ex4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# assign an integer for cars variable
cars = 100
# assign a float for the space_in_a_car variable
space_in_a_car = 4.0
# assign an integer for drivers variable
drivers = 30
# assign an integer for passengers variables
passengers = 90
# use the above assigned variables to create an equation
cars_not_driven = cars - drivers
# assign the drivers variable amount to this variable name
cars_driven = drivers
# create an equaiton of above assigned variables
carpool_capacity = cars_driven * space_in_a_car
# create an equation of above assigned variables
average_passengers_per_car = passengers / cars_driven

# utilizing the assigned variable to complete the phrase
puts "There are #{cars} cars available."
puts "There are only #{drivers} drivers available."
# utilizing the assigned variable to complete the phrase, an eqation was done above to reach this number
puts "There will be #{cars_not_driven} empty cars today."
puts "We can transport #{carpool_capacity} people today."
puts "We have #{passengers} to carpool today."
puts "We need to put about #{average_passengers_per_car} in each car."


# Study drills

# The mistake that was given I was able to recreate by not putting double quotations around line 14. There was a specification for what line 14 was being asked to do.
24 changes: 24 additions & 0 deletions day_1/ex5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name = 'Zed A. Shaw'
age = 35 # not a lie in 2009
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
centimeter = 2.54
kilogram = 2.2046
rounded = 81.6

puts "Let's talk about #{name}."
puts "He's #{height} inches tall."
puts "He's #{weight} pounds heavy."
puts "Actually that's not too heavy."
puts "He's got #{eyes} eyes and #{hair} hair."
puts "His teeth are usually #{teeth} depending on the coffee."

# this line is tricky, try to get it exactly right
puts "If I add #{age}, #{height}, and #{weight} I get #{age + height + weight}."
puts "#{name} is #{height * centimeter} centimeters tall."
puts "#{name} is #{weight / kilogram} kilograms."
puts "Wow, #{weight / kilogram} kilograms is quite a number!"
puts "Let's round that out to #{rounded} kilograms, that's better."
37 changes: 37 additions & 0 deletions day_1/ex6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# assign integer to variable
types_of_people = 10
# assign string to variable with integer assigned in string
x = "There are #{types_of_people} types of people."
# assign string to variable
binary = "binary"
# assign string to variable
do_not = "don't"
# assign string to variable with two separate strings assigned within
y = "Those who know #{binary} and those who #{do_not}."
# print out above assigned variables
puts x
# print out above assigned variables
puts y
# print out sentence with above assigned variables within string
puts "I said: #{x}."
# print out sentence with above assigned variables within string
puts "I also said: '#{y}'."
# assign boolean value
hilarious = false
# assign string with boolean variable within
joke_evaluation = "Isn't that joke so funny?! #{hilarious}"
# print out above assigned variable with boolean in string
puts joke_evaluation
# assign string to variable
w = "This is the left side of..."
# assign string to variable
e = "a string with a right side."
# print out combined variables
puts w + e


# Study Drills

# 2. & 3. I only see four places, the other places where there is a data type inside a string the data type is either an integer or a boolean.
# 4. Combining the two variables "w" and "e" create on longer string because we haven't specified where the combined string should end, therefore they are put together.
# 5. One can use single quotes versus double quotes, but in this instance because we have words in our strings that are contractions (and aren't assigned to a contraction by a string like the "do_not = don't" example) then putting a single quote prematurely ends our string. We could change the word on line 22 "Isn't" to "Is not" and then could use single quotes.
22 changes: 22 additions & 0 deletions day_1/ex7.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
print "How old are you? "
age = gets.chomp
print "How tall are you? "
height = gets.chomp
print "How much do you weigh? "
weight = gets.chomp

puts "So, you're #{age} old, #{height} tall and #{weight} heavy."

print "Where do you live? "
home = gets.chomp
print "How long have you lived there? "
time = gets.chomp

puts "You've lived in #{home} for #{time}, wow that's great!"

# I was very confused on where "gets.chomp" got it's input from. I didn't
# understand how the program knew what age, height or weight I was. After
# googling for two days I finally reached out to a peer and was able to find
# out the information I was missing; I needed to answer the questions being
# posed in my terminal. Genius! This one tripped me up but I learned a lot of
# great lessons from it.
4 changes: 2 additions & 2 deletions day_1/exercises/interpolation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
speedy = "quick red fox"
slow_poke = "lazy brown dog"

p # YOUR CODE HERE
p "The #{speedy} jumped over the #{slow_poke}"

# Write code that uses the variables below to form a string that reads
# "In a predictable result, the tortoise beat the hare!":
slow_poke = "tortoise"
speedy = "hare"

# YOUR CODE HERE
p "In a predicatable result, the #{slow_poke} beat the #{speedy}!"
8 changes: 5 additions & 3 deletions day_1/exercises/loops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@

# Example: Write code that prints your name five times:
5.times do
p "Hermione Granger"
p "Leigh Cepriano Pulzone"
end

# Write code that prints the sum of 2 plus 2 seven times:
7.times do
# YOUR CODE HERE
p 2 + 2
end

# Write code that prints the phrase 'She sells seashells down by the seashore'
# ten times:
# YOUR CODE HERE
10.times do
p "She sells seashells down by the seashore"
end
8 changes: 4 additions & 4 deletions day_1/exercises/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
# `ruby day_1/exercises/numbers.rb`

# Example: Write code that prints the result of the sum of 2 and 2:
p 2 + 2
puts "What is 2 + 2? #{2 + 2}"

# Write code that prints the result of 7 subtracted from 83:
p #YOUR CODE HERE
puts "What is 7 subtracted from 83? #{7 - 83}"

# Write code that prints the result of 6 multiplied by 53:
# YOUR CODE HERE
puts "What is 6 times 53? #{6 * 53}"

# Write code that prints the result of the modulo of 10 into 54:
# YOUR CODE HERE
puts "What is the modulo of 10 divided by 54? #{10 % 54}"
17 changes: 14 additions & 3 deletions day_1/exercises/strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@
# `ruby day_1/exercises/strings.rb`

# Example: Write code that prints your name to the terminal:
p "Alan Turing"
name = "Leigh Cepriano Pulzone"
puts name

# Write code that prints `Welcome to Turing!` to the terminal:
p #YOUR CODE HERE
greeting = "Welcome to Turing!"
puts greeting

# Write code that prints `99 bottles of pop on the wall...` to the terminal:
# YOUR CODE HERE
little_diddy = "99 bottles of pop on the wall..."
puts little_diddy

# I played around with "p", "print" and "puts" here and was very interested in
# what I saw in my terminal! I will be digging deeper into the difference between
# all of the options to find what different situations will call for them as I'm
# sure there is a reason why all three do the same thing with slight differences.
# At first I had the strings put into sentences that would print out such as
# "My name is #{name}." But I then changed it to print out just my name as the
# directions specified, I will happily go back and change it if need be!
23 changes: 16 additions & 7 deletions day_1/exercises/variables.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,38 @@
# In the below exercises, write code that achieves
# the desired result. To check your work, run this
# file by entering the following command in your terminal:
# file by entering the following command in your terminal:
# `ruby day_1/exercises/variables.rb`

# Example: Write code that saves your name to a variable and
# prints what that variable holds to the terminal:
name = "Harry Potter"
name = "Leigh Cepriano Pulzone"
p name

# Write code that saves the string 'Dobby' to a variable and
# prints what that variable holds to the terminal:
house_elf = "Dobby"
# YOUR CODE HERE
free_house_elf = "Dobby"
p free_house_elf

# Write code that saves the string 'Harry Potter must not return to Hogwarts!'
# and prints what that variable holds to the terminal:
# YOUR CODE HERE
chamber_of_secrets = "Harry Potter must not return to Hogwarts!"
p chamber_of_secrets

# Write code that adds 2 to the `students` variable and
# prints the result:
students = 22
# YOUR CODE HERE
students = 22 + 2
p students


# Write code that subracts 2 from the `students` variable and
# prints the result:
# YOUR CODE HERE
students = 22 - 2
p students

# I was unsure if I was being asked to reassign the variable 'students' by typing
# students = 22 + 2 or if I was supposed to create a new variable with the
# variable 'students' in it.
# Also, it was not until I got to the interpolation exercise that I realized the
# first line was just an example which is why you will see all the examples changed.
# What another great lesson learned, read the fine print (maybe a few times...)!
8 changes: 8 additions & 0 deletions day_1/need_to_calculate.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
puts "How many live shrimp are in the bowl?"

puts "Let's find out."


puts "Alive #{2 + 4 + 6 + 8 / 2}"
puts "Dead #{3 + 5 - 2 * 2}"
puts "There is more alive than dead. #{16 > 4}"
3 changes: 3 additions & 0 deletions day_1/numbers_ruby_in_100_minutes.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
5.times do
puts "Hello, World!"
end
60 changes: 53 additions & 7 deletions day_1/questions.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,63 @@
## Day 1 Questions

1. How would you print the string `"Hello World!"` to the terminal?
* I would print the string `"Hello World"` in the terminal by typing in
```
p "Hello World"
```

1. What character is used to indicate comments in a ruby file?

1. Explain the difference between an integer and a float?
2. What character is used to indicate comments in a ruby file?
* The `#` character will indicate comments in a ruby file without printing it.

1. In the space below, create a variable `animal` that holds the string `"zebra"`

1. How would you print the string `"zebra"` using the variable that you created above?
3. Explain the difference between an integer and a float?
* The difference between an integer and a float is that a float has a decimal
point `0.001` is an example of a float. This can also be a float `1.0`. An
integer is a number without a decimal point `23` is an integer, so is `-3`.

1. What is interpolation? Use interpolation to print a sentence using the variable `animal`.

1. What method is used to get input from a user?
4. In the space below, create a variable `animal` that holds the string `"zebra"`
```
animal = "zebra"
```

1. Name and describe two common string methods:

5. How would you print the string `"zebra"` using the variable that you created above?
* `p animal`


6. What is interpolation? Use interpolation to print a sentence using the variable `animal`.
* Interpolation is putting strings together, I think about it like a collage of strings.
```
example:
animal = "zebra"
p "I want to ride a #{animal} someday."
"I want to ride a zebra someday."
```


7. What method is used to get input from a user?
* The `gets` method is used to get input from a user.


8. Name and describe two common string methods:
* `length` is a method that is used to count the amount of characters in a string
```
Example:
name = "Leigh"
p name.length
5
```

* `times` is a method that is used to repeat the times a string is printed by the amount put in before.

```
Example:
3.times do
p "Hello"
end
"Hello"
"Hello"
"Hello"
```
Loading