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

Austin Andrade #434

Open
wants to merge 8 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
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
7 changes: 7 additions & 0 deletions day_1/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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."
2 changes: 2 additions & 0 deletions day_1/ex2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
puts "I could have code like this."
puts "This will run."
25 changes: 25 additions & 0 deletions day_1/ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
puts "I will now count my chickens:"

#Adds 25 to 30/6
puts "Hens #{25 + 30 / 6}"

puts "Roosters #{100 - 25 * 3 % 4}"

puts "Now I will count the eggs:"

puts "#{3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6}"

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

puts "#{3 + 2 < 5 - 7}"

puts "What is 3 + 2? #{3 + 2}"
puts "What is 5 - 7? #{5 - 7}"

puts "Oh, that's why it's false."

puts "How about some more."

puts "Is it greater? #{5 > -2}"
puts "Is it greater or equal? #{5 >= -2}"
puts "Is it less or equal? #{5 <= -2}"
15 changes: 15 additions & 0 deletions day_1/ex4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cars = 100
space_in_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_car
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."
16 changes: 16 additions & 0 deletions day_1/ex5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name = 'Zed A. Shaw'
age = 35 # not a lie in 2009
height = 74 # inches
weight = 180 # Ibs
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}."
21 changes: 21 additions & 0 deletions day_1/ex6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
types_of_people = 10
x = "There are #{types_of_people} types of people."
binary = "binary"
do_not = "don't"
y = "Those who know #{binary} and those who #{do_not}."

puts x
puts y

puts "I said: #{x}."
puts "I also said: '#{y}'."

hilarious = false
joke_evaluation = "Isn't that joke so funny?! #{hilarious}"

puts joke_evaluation

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

puts w + e
8 changes: 8 additions & 0 deletions day_1/ex7.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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."
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 predictable result, the #{slow_poke} beat the #{speedy}!"
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}"
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
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

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

# Write code that prints the result of the modulo of 10 into 54:
# YOUR CODE HERE
p 54 % 10
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!"

# 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..."
13 changes: 6 additions & 7 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,18 @@
# 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

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

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

# Write code that subracts 2 from the `students` variable and
# prints the result:
# YOUR CODE HERE
p students
p "#{students - 2}"
17 changes: 17 additions & 0 deletions day_1/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,33 @@

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

To print the string `"Hello World!"` to the terminal, simply type
`puts "Hello World!"`

1. What character is used to indicate comments in a ruby file?
The hashtag or octothorpe `#` character is used to indicate comments in a ruby file.

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

An integer is a whole number ("1", "2", "3"), where a float is a decimal ("1.1", "2.2", "3.3")

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

animal = "zebra"

1. How would you print the string `"zebra"` using the variable that you created above?

p animal

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

p "The #{animal} is one of the main meals of lions."

1. What method is used to get input from a user?

`gets.chomp`

1. Name and describe two common string methods:

`.times do` repeats the given string x amount of times.
`.size` calculated character length of a given string.
7 changes: 7 additions & 0 deletions day_2/exercises/array_methods.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
`.each` returns one block for each element and denoting that element as a parameter.

`.collect` "Returns a new array containing the values returned by the block."

`.first` & `.last` returns the first and last elements noted within an array.

`.shuffle` moves the elements to random positions within an array.
16 changes: 9 additions & 7 deletions day_2/exercises/arrays.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,33 @@

# Write code that stores an array of states in a variable,
# then prints that array:
states = #YOUR CODE HERE
states = ["Ohio", "Colorado", "Wyoming"]
p states

# Write code that stores an array of foods in a variable,
# then prints that array:
# YOUR CODE HERE
foods = ["Apple", "Pizza", "Coconut"]
p foods

# Example: Write code that prints the number of elements
# in your above array of animals:
p animals.count

# Write code that prints the number of elements
# in your above array of foods:
# YOUR CODE HERE
p foods.count

# Write code that prints "Zebra" from your animals array:
# YOUR CODE HERE
p animals.first

# Write code that prints the last item of your foods array:
# YOUR CODE HERE
p foods.last

# Write code that adds "lion" to your animals array
# and prints the result (Hint- use a method):
# YOUR CODE HERE
p animals << "lion"

# Write code that removes the last element from your foods array
# and prints the result (Hint- use a method):
# YOUR CODE HERE
foods.pop
p foods
16 changes: 16 additions & 0 deletions day_2/exercises/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
numbs = ["1", "2", "3", "4"]
numbs.each { |n| print n * 2, " "}
numbs.each { |n| print n * 3, " "}

numbs = (1..4).to_a
numbs.each { |x| puts x if x.even? }

numbs = (1..4).to_a
numbs.each { |x| puts x if x.odd? }

numbs = (1..4).to_a
numbs.map! { |a| puts 2**a }

names = ["Alice Smith", "Bob Evans", "Roy Rogers"]
names.each {|name| puts name }
names.take(1)
9 changes: 9 additions & 0 deletions day_2/exercises/ex2.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"&&" = and
"| |" = or
"!" = not
"!=" = not equal
"==" = equal
">=" greater than or equal
"<=" less than or equal
true = true
false = false
16 changes: 10 additions & 6 deletions day_2/exercises/iteration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,18 @@
# "The <animal> is awesome!" for each animal:

animals.each do |animal|
# YOUR CODE HERE
p "The #{animal} is awesome!"
end

# Write code that stores an array of foods in a variable,
# Write code that stores an array of foods in a variable,
# then iterates over that array to print
# "Add <food> to shopping list" for each food item:
# YOUR CODE HERE
foods = ["Apple", "Chicken", "Taco"]

# Write code that stores an array of numbers in a variable,
# then iterates over that array to print doubles of each number:
# YOUR CODE HERE
foods.each do |food|
p "Add #{food} to shopping list"
end
# Write code that stores an array of numbers in a variable,
# then iterates over that array to print doubles of each number:
numbs = ["2", "4", "6", "8"]
numbs.each { |n| print n * 2, " "}
27 changes: 27 additions & 0 deletions day_2/questions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,43 @@

1. Create an array containing the following strings: `"zebra", "giraffe", "elephant"`.

["zebra", "giraffe", "elephant"]

1. Save the array you created above to a variable `animals`.

animals = ["zebra", "giraffe", "elephant"]

1. Using the array `animals`, how would you access `"giraffe"`?

animals[1]

1. How would you add `"lion"` to the `animals` array?

p animals << "lion"

1. Name and describe two additional array methods:

`.take` returns the first n elements from an array.
`.drop` returns elements after the first n elements are dropped.

1. What are the boolean values in Ruby?

"&&"
"| |"
"!"
"!="
"=="
">="
"<="
true
false

1. In Ruby, how would you evaluate if `2` is equal to `25`? What is the result of this evaluation?

2 == 25
false

1. In Ruby, how would you evaluate if `25` is greater than `2`? What is the result of this evaluation?

25 > 2
true
Loading