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

Logan Anderson #442

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
16 changes: 8 additions & 8 deletions day_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ This will open the day_1 directory in Atom. You should be able to see the direct

1. Check off the items below as you complete the steps you just read for each lesson. ***Remember to create a file containing your work for each lesson!***

- [ ] [A Good First Program](https://learnrubythehardway.org/book/ex1.html)
- [x] [A Good First Program](https://learnrubythehardway.org/book/ex1.html)

- [ ] [Comments in Code](https://learnrubythehardway.org/book/ex2.html)
- [x] [Comments in Code](https://learnrubythehardway.org/book/ex2.html)

- [ ] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html)
- [x] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html)

- [ ] [Variables and Names](https://learnrubythehardway.org/book/ex4.html)
- [x] [Variables and Names](https://learnrubythehardway.org/book/ex4.html)

- [ ] [Strings](https://learnrubythehardway.org/book/ex5.html)
- [x] [Strings](https://learnrubythehardway.org/book/ex5.html)

- [ ] [More Strings](https://learnrubythehardway.org/book/ex6.html)
- [x] [More Strings](https://learnrubythehardway.org/book/ex6.html)

- [ ] [Asking for Input](https://learnrubythehardway.org/book/ex11.html)
- [x] [Asking for Input](https://learnrubythehardway.org/book/ex11.html)

- [ ] Have you created 7 `ex.rb` files with your code in them?
- [x] Have you created 7 `ex.rb` files with your code in them?

1. Work through the [Strings](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#3.-strings) and [Numbers](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#5.-numbers) sections from Ruby in 100 Minutes. For each of these sections, open an `irb` session by typing `irb` into your terminal and type in the code snippets provided.

Expand Down
10 changes: 10 additions & 0 deletions day_1/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#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 'Study drill extra line!'

# The pound symbol allows you to make comments on your code
11 changes: 11 additions & 0 deletions day_1/ex2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# 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."

# I was correct on what the "#" character does.
48 changes: 48 additions & 0 deletions day_1/ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# prints string
puts "I will now count my chickens:"

# prints string with mathematical interpolation
puts "Hens #{25.0 + 30.0 / 6.0}"
# prints string with mathematical interpolation
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"

# prints string
puts "Now I will count the eggs:"

# prints solution to math problem
puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0

# prints string
puts "Is it true that 3 + 2 < 5 - 7?"

# calculates value of each side of the inequality, compares, returns true or false
puts 3.0 + 2.0 < 5.0 - 7.0

# prints string with mathematical interpolation
puts "What is 3 + 2? #{3.0 + 2.0}"
# prints string with mathematical interpolation
puts "What is 5 - 7? #{5.0 - 7.0}"

# prints string
puts "Oh, that's why it's false."

# prints string
puts "How about some more."

# prints string with interpolation that compares the values and returns true or false
puts "Is it greater? #{5.0 > -2.0}"
# prints string with interpolation that compares the values and returns true or false
puts "Is it greater or equal? #{5.0 >= -2.0}"
# prints string with interpolation that compares the values and returns true or false
puts "Is it less or equal? #{5.0 <= -2.0}"

# + plus does addition
# - minus does subtraction
# / slash does division
# * asterisk does multiplication
# % percent returns the remainder of the left number divided by the right number
# < less-than compares to see if left side is mathematically less than right side
# > greater-than compares to see if left side is mathematically greater than right side
# <= less-than-equal compares to see if left side is mathematically less than or equal to right side
# >= greater-than-equal compares to see if left side is mathematically greater than or equal to left side
# <, >, <=, >= all return true or false value
4 changes: 4 additions & 0 deletions day_1/ex3_drill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
puts "Amount of money in my wallet: #{21.00 + 7.00}"
puts "Cost of meal at restaurant:#{12.99 + 2.60}"

puts "I have enough money to buy the meal: #{21.00 + 7.00 >= 12.99 + 2.60}"
27 changes: 27 additions & 0 deletions day_1/ex4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# There are 100 cars
cars = 100
# You can fit 4 passengers in a car
space_in_a_car = 4.0
# There are only 30 drivers available for the 100 cars
drivers = 30
# They need to transport 90 people
passengers = 90
# One driver per car means that subtracting drivers from cars returns the number of empty cars
cars_not_driven = cars - drivers
# cars_driven can only be as large as the number of drivers available to drive them
cars_driven = drivers
# The total number of seats available is determined by multiplying the number of cars available by the number of seats available per car
carpool_capacity = cars_driven * space_in_a_car
# To determine how to divide passangers among the cars you just need to divide the number of passengers by the number of cars driven
average_passengers_per_car = passengers / cars_driven


puts "There are #{cars} cars available."
puts "There are only #{drivers} drivers available."
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."

# 1. The error that the author received was stating that the variable carpool_capacity was not properly assigned a value
# 2. I don't believe that it is necessary for space_in_a_car to be a float because you can't have a partial seat as you can't have a partial person to fill it
19 changes: 19 additions & 0 deletions day_1/ex5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name = 'Zed A. Shaw'
age = 35
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'

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."

puts "If I add #{age}, #{height}, and #{weight} I get #{age + height + weight}."

puts "Being #{height} inches tall means that #{name} is #{height * 2.54} centimeters tall."
puts "And weighing #{weight} pounds means that #{name} weighs #{weight * 0.45} kilograms."
41 changes: 41 additions & 0 deletions day_1/ex6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# assigns the variable to the value of 10
types_of_people = 10
# makes a string variable that interpolates the previous variable
x = "There are #{types_of_people} types of people."
# a new string variable
binary = "binary"
# a new string variable
do_not = "don't"
# makes a string variable that interpolates the previous 2 variables
y = "Those who know #{binary} and those who #{do_not}."

# prints variable x with interpolation
puts x
# prints variable y with interpolation
puts y

# prints string that interpolates variable x
puts "I said #{x}."
# prints string that interpolates variable y
puts "I also said: '#{y}'."

# creates variable with boolean value false
hilarious = false
# makes a string variable that interpolates the previous variable
joke_evaluation = "Isn't that joke so funny?! #{hilarious}"

# prints variable joke_evaluation that interpolates variable hilarious
puts joke_evaluation

# a new string variable
w = "This is the left side of ..."
# a new string variable
e = "a string with a right side."

# prints both listed variables from left to right
puts w + e

# 2. lines: 10, 10, 18, 20
# 3. I believe there are only 4 places because line 4 interpolates an integer and line 25 interpolates a boolean
# 4. I am guessing that adding the two strings using a + makes a longer string because using that math function tells ruby to combine the two strings into 1
# 5. changing the strings to use single instead of double quotes breaks the program, I think that is because string will only interpolate with double quotes and using the single quotes comments out everything after the pound in the string
18 changes: 18 additions & 0 deletions day_1/ex7.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
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."

# 1. The gets portion creates a new line that makes a new value of user input while the .chomp portion removes the line break
# 2. Another way I can think of to use .chomp would be to do the same thing we did in an earlier exercise that did puts x + y

x = "This is the left part of a string ..."
y = "that has a right part."

print x.chomp
print y

24 changes: 24 additions & 0 deletions day_1/ex7_drill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
print "Do you know Jimmy? "
friend = gets.chomp.downcase

if friend == "yes"
print "Does he live on Main Street? "
home = gets.chomp.downcase

if home == "yes"
print "Awesome, I'll head there now!"
else
print "Okay I'll figure it out then."
end

else
print "Do you know his roommate Bob? "
friend2 = gets.chomp.downcase

if friend2 == "yes"
print "If you could give me his phone number that would be great."
else
print "Oh, nevermind then I'll ask Greg."
end

end
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}" # YOUR CODE HERE

# 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 predictable result, the #{slow_poke} beat the #{speedy}!" # YOUR CODE HERE
6 changes: 4 additions & 2 deletions day_1/exercises/loops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@

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

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

# Write code that prints the result of 7 subtracted from 83:
p #YOUR CODE HERE
p 83 - 7 #YOUR CODE HERE

# Write code that prints the result of 6 multiplied by 53:
# YOUR CODE HERE
p 6 * 53 # YOUR CODE HERE

# Write code that prints the result of the modulo of 10 into 54:
# YOUR CODE HERE
p 54 % 10 # YOUR CODE HERE
4 changes: 2 additions & 2 deletions day_1/exercises/strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
p "Alan Turing"

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

# Write code that prints `99 bottles of pop on the wall...` to the terminal:
# YOUR CODE HERE
p "99 bottles of pop on the wall..." # YOUR CODE HERE
11 changes: 6 additions & 5 deletions day_1/exercises/variables.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 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
Expand All @@ -11,19 +11,20 @@
# 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
p house_elf # YOUR CODE HERE

# 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
safety = "Harry Potter must not return to Hogwarts!" # YOUR CODE HERE
p safety

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

# Write code that subracts 2 from the `students` variable and
# prints the result:
# YOUR CODE HERE
students = students - 2 # YOUR CODE HERE
p students
46 changes: 32 additions & 14 deletions day_1/questions.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,35 @@
## Day 1 Questions

1. How would you print the string `"Hello World!"` to the terminal?

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

1. Explain the difference between an integer and a float?

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?

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?

1. Name and describe two common string methods:
```ruby
p "Hello World!"
```

2. What character is used to indicate comments in a ruby file?
- The pound symbol (#)

3. Explain the difference between an integer and a float?
- A float uses decimals

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

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

6. What is interpolation? Use interpolation to print a sentence using the variable `animal`.
- Interpolation is a way to process code inside of a string
```ruby
animal = "zebra"
p "A #{animal} is often recognized for having black and white stripes."
```

7. What method is used to get input from a user?
- Input can be gotten using "gets" or if you want it in the same line you would use "gets.chomp"

8. Name and describe two common string methods:
- One method is the ".split" method which breaks up string based on a specified criteria and returns an array. Another method is the ".sub" method which allows one to find and replace specific things within a string.
6 changes: 3 additions & 3 deletions day_2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Using your terminal, open your local copy of the forked repository you created d
1. Work through the [Arrays](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#7.-arrays) section of Ruby in 100 Minutes. As you work through this section, research each of the methods mentioned by looking through the [Ruby docs for Arrays](https://ruby-doc.org/core-2.4.1/Array.html). Documentation like this might look intimidating, but diving in and practicing now will build your comfort level. Create a file in your day_2 directory called `array_methods.md` and describe what each method does in your own words.
1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory.

- [ ] Turing's [Iteration and Each](http://backend.turing.io/module1/lessons/iteration_and_each) lesson.
- [x] Turing's [Iteration and Each](http://backend.turing.io/module1/lessons/iteration_and_each) lesson.

- [ ] [Booleans](https://learnrubythehardway.org/book/ex27.html) from Learn Ruby the Hard Way.
- [x] [Booleans](https://learnrubythehardway.org/book/ex27.html) from Learn Ruby the Hard Way.

- [ ] [Boolean Practice](https://learnrubythehardway.org/book/ex28.html) from Learn Ruby the Hard Way.
- [x] [Boolean Practice](https://learnrubythehardway.org/book/ex28.html) from Learn Ruby the Hard Way.

1. Work through the exercise files in the day_2/exercises directory. Complete them in this order:
1. arrays
Expand Down
Loading