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

Wyatt Wicks #433

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Empty file added day_0/_secret_library/Gemfile
Empty file.
Empty file added day_0/_secret_library/README.md
Empty file.
Empty file added day_0/_secret_library/Rakefile
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions day_1/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"Hello World!"
"hello Again"
"I like typing this."
"this is fun."
"yay! Printing."
#puts "I'd much rather you 'not'."
'I "said" do not touch this.'
"another line"
9 changes: 9 additions & 0 deletions day_1/ex2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# 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."
2 changes: 2 additions & 0 deletions day_1/ex3-5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
puts "How long will my next break be if I need to let the dogs out for 5 minutes, and drink coffee for 2 minutes"
puts 5 + 2
30 changes: 30 additions & 0 deletions day_1/ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This will print the following phrase
puts "I will now count my chickens:"

#This will print the following phrases with the answers to the math problems inbetween the brackets
puts "Hens #{25.0 + 30.0 / 6.0}"
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"

#This will print the following phrase
puts "Now I will count the eggs:"

#This will print the answer to the math problem below
puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.0 + 6.0

#This will print the following phrase without doing the math problem as the math is not in brackets
puts "Is it true that 3 + 2 < 5 - 7?"

#This will print if the following math problem is true or false
puts 3.0 + 2.0 < 5.0 - 7.0

#This will print the following phrases with the answers to the math problems in brackets
puts "What is 3 + 2? #{3.0 + 2.0}"
puts "What is 5 - 7? #{5.0 - 7.0}"

#This will print the following phrases
puts "Oh, that's why it's false."
puts "How about some more."
# This will print the following phrases including the answers to the the true/false math problems below. They will say true or false.
puts "Is it greater? #{5.0 > -2.0}"
puts "Is greater or equal? #{5.0 >= -2.0}"
puts "Is it less or equal? #{5.0 <= -2.0}"
33 changes: 33 additions & 0 deletions day_1/ex4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#This assigns the variable cars the value of 100
cars = 100

#This assigns the variable space_in_a_car the value of 4.0
space_in_a_car = 4.0

#This assigns the variable drivers the value of 30
drivers = 30

#This assigns the variable passengers the value of 90
passengers = 90

#This assigns the variable cars_not_driven the value of the variable cars minus the value of the variable drivers
cars_not_driven = cars - drivers

#This assigns the variable cars_driven the same value as the variable drivers
cars_driven = drivers

#This assigns the variable carpool_capacity the value of the variable cars_driven multiplied by the variable space_in_a_car
carpool_capacity = cars_driven * space_in_a_car

#This assigns the variable average_passengers_per_car the value of the variable passengers divided by the variable 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."

#Answer to study drill question 1: If you do not use a float number, the answer will be a whole number rounded to the nearest digit.
20 changes: 20 additions & 0 deletions day_1/ex5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name = 'Zed A. Shaw'
age = 35 # not a lie in 2009
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'

height_in_cm = height * 2.54
weight_in_kg = weight * 0.453592

puts "Let's talk about #{name}"
puts "He's #{height_in_cm} centimeters tall."
puts "He's #{weight_in_kg} kilograms 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}."
36 changes: 36 additions & 0 deletions day_1/ex6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# variable assignment for types_of_people
types_of_people = 10

# variable assignment for x where value is a string that includes a variable as well
x = "There are #{types_of_people} types of people."

# assign values for 2 variables
binary = "binary"
do_not = "don't"

# assigns a value that includes a string and 2 other variables to y
y = "Those who know #{binary} and those who #{do_not}."

#These commands print the value of the variables x and y
puts x
puts y

#These commands print strings along with the values of the variables assigned to x and y
puts "I said: #{x}."
puts "I also said: '#{y}'."

# this assigns a boolean value to the variable 'hilarious'
hilarious = false

# this assigns a value to joke_evaluation that includes a string as well as the value of 'hilarious'
joke_evaluation = "Isn't that joke so funny?! #{hilarious}"

# this prints the value of joke_evaluation
puts joke_evaluation

# these commands assign values to w and e and then prints the value of them added together.
w = "This is the left side of..."
e = "a string with a right side."
puts w + e

#Study Drills answers: 3. there are 4 places where a string is inside of a string, the rest are not strings as the variables do not have quotation marks. 3. you are adding two strings together, making them longer. 4. Single quotes only work where the thing will not be in double quotes as that would confuse the terminal into thinking they are seperate strings.
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 10 % 54
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..."
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

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

# 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
16 changes: 10 additions & 6 deletions day_1/questions.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
## Day 1 Questions

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

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

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

an integer is a whole number, a float has decimals i.e. not a whole number.
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`.

It is a method of printing a string with variables inside it.
p "My favorite animal is a #{animal}"
1. What method is used to get input from a user?

the 'gets' command.
1. Name and describe two common string methods:
"string".size will show how many characters are in the string.
"string".strip will remove all extra space from the string.
8 changes: 8 additions & 0 deletions day_2/array_method.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.sort This will sort the items in your array alphabetically if they are strings, or ascending value order if they are numbers.
.each This will select all the elements in the array that fit whatever parameters you want and changes them based on the parameters you type.
.join will combine elements in an array in to a string.
.index will show the position of each thing in the array.
.collect will will create a new array for the values returned in the paramters you choose.
.first will return the first thing in the array.
.last will collect the last thing in the array.
.shuffle will give a new array with all of the elements shuffled to new positions.
17 changes: 10 additions & 7 deletions day_2/exercises/arrays.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,34 @@

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

# Write code that stores an array of foods in a variable,
# then prints that array:
# YOUR CODE HERE
foods = ["grape", "mushroom", "beef"]
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[0]

# 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
animals.insert(3, "lion")
p animals

# 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
28 changes: 28 additions & 0 deletions day_2/exercises/boolean_practice.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
true && true is true
false && true is false
1 == 1 && 2 == 1 is false
"test" == "test" is true
1 == 1 || 2 != 1 is true
true && 1 == 1 is true
false && 0 !=0 is false
true || 1 == 1 is true
"test" == "testing" is false
1 != 0 && 2 == 1 is false
"test" != "testing" is true
"test" == 1 is false
!(true && false) is true
!(1 == 1 && 0 != 1) is false
!(10 == 1 || 1000 == 1000) is false
!(1 != 10 || 3 == 4) is false
!("testing" == "testing" && "Zed" == "Cool Guy") is true
1 == 1 && (!("testing" == 1|| 1 == 0)) is true
"chunky" == "bacon" && (!(3 == 4 || 3 == 3)) is false
3 == 3 && (!("testing" == "testing" || "Ruby" == "Fun")) is false

&& (and)
|| (or)
! (not)
!= (not equal)
== (equal)
>= (greater-than-equal)
<= (less-than-equal)
19 changes: 13 additions & 6 deletions day_2/exercises/iteration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,21 @@
# "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 = ["sugar", "watermelon", "eggs"]
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:
# YOUR CODE HERE
# Write code that stores an array of numbers in a variable,
# then iterates over that array to print doubles of each number:
numbers = [1, 2, 3, 4]
numbers.each do |number|
p 2 * number
end
Loading