diff --git a/final_prep/README.md b/final_prep/README.md
index 22bfb5154..6d1f602e2 100644
--- a/final_prep/README.md
+++ b/final_prep/README.md
@@ -32,24 +32,24 @@ In Mod 0 you've learned about different techniques for managing your time at Tur
When you are finished, add screenshots of your calendar so we can provide feedback if needed!
-- `Add Week 1 Screenshot Here`
-- `Add Week 2 Screenshot Here`
-- `Add Week 3 Screenshot Here`
+- `Add Week 1 Screenshot Here`
+- `Add Week 2 Screenshot Here`
+
+- `Add Week 3 Screenshot Here`
### Mentorship Prep
Mentorship is an integral part of the Turing experience and will help jumpstart your technical career. In order to get your mentor relationship started on the right foot, please complete the following deliverables:
- [ ] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c)
- - [ ] Add link to your gist here:
-
+ - [ ] Add link to your gist here: [https://gist.github.com/AliciaWatt/65e82d635819de7bf579655406a3d158)
### Lesson Prep
You've learned a lot about how to take strong notes during Mod 0. Show us your skills while you learn how to pre-teach content for your first lesson in Mod 1!
- [ ] Complete the [Pre Teaching Practice exercise](https://gist.github.com/ericweissman/0036e8fe272c02bd6d4bb14f42fd2f79) gist
- - [ ] Add a link to your gist here:
+ - [ ] Add a link to your gist here: [https://gist.github.com/AliciaWatt/bc2ee62216c1a86397081c8dbcf11399)
### Group Work Prep
As part of Turing's project-based learning approach, you will often be working in pairs or larger groups. In order to set yourself (and your team) up for success, it is important to ensure you are prepared to be an equitable contributor and teammate.
- [ ] Complete the [DTR Guiding Questions](https://gist.github.com/ericweissman/c56f3a98cdce761808c21d498a52f5c6)
- - [ ] Add a link to your gist here:
+ - [ ] Add a link to your gist here: [https://gist.github.com/AliciaWatt/9191a0996df43704865b1fb44f1c9a00)
## All Done? How to Submit your M1 Prework
When you have completed *all* the activities described above, follow the steps below to submit your technical prework.
@@ -86,4 +86,4 @@ What is your plan and how are you going to hold yourself to it? Specifically...
- What personal items/events are important to you during this time? How are you going to make sure those are not neglected? (Hint, block time on the calendar for them!)
## Extensions
-Check out our thoughts on [extension activities](https://mod0.turing.io/prework/extensions) if you find yourself with some extra time before starting Mod 1!
\ No newline at end of file
+Check out our thoughts on [extension activities](https://mod0.turing.io/prework/extensions) if you find yourself with some extra time before starting Mod 1!
diff --git a/final_prep/annotations.rb b/final_prep/annotations.rb
index 8b938706c..ae99a34d8 100644
--- a/final_prep/annotations.rb
+++ b/final_prep/annotations.rb
@@ -3,41 +3,67 @@
# Use the # to create a new comment
# Build a Bear
-
+#define the function or method using def and add agruments
def build_a_bear(name, age, fur, clothes, special_power)
+ #upack the arguments by defining the variables
greeting = "Hey partner! My name is #{name} - will you be my friend?!"
+#this is an array
demographics = [name, age]
+ #this is a string with an argument in it
power_saying = "Did you know that I can #{special_power}?"
+#this is a hash
built_bear = {
+ #this is a string
'basic_info' => demographics,
+ #this is also a string
'clothes' => clothes,
+ #string again
'exterior' => fur,
+ #integer
'cost' => 49.99,
+ #string with argumentnts inside
'sayings' => [greeting, power_saying, "Goodnight my friend!"],
+ #boolean value
'is_cuddly' => true,
}
+ #this is a return statment
return built_bear
+ #this ends the function
end
-
+# this is calling the function build_a_bear with values
build_a_bear('Fluffy', 4, 'brown', ['pants', 'jorts', 'tanktop'], 'give you nightmares')
+#this is another set of values
build_a_bear('Sleepy', 2, 'purple', ['pajamas', 'sleeping cap'], 'sleeping in')
# FizzBuzz
-
+# defineing the method with lowercase name declaring the arguments
def fizzbuzz(num_1, num_2, range)
+ #the range operator and the each do is for loops
(1..range).each do |i|
+ # if i modulus num_1 equals 0 and i modulus num_2 equals 0
if i % num_1 === 0 && i % num_2 === 0
+ #if true print 'fizzbuzz'
puts 'fizzbuzz'
+ #elsif gives another step if the first equation is false
elsif i % num_1 === 0
+ #if true prints fizz
puts 'fizz'
+ #another option
elsif i % num_2 === 0
+ #if true prints buzz
puts 'buzz'
+ #else is the last use in the if - statment
else
+ #if none of the above are true prints i
puts i
+ #end if statment
end
+ #ends .each do
end
+ #ends the method
end
-
+#calls fizzbuzz method with values 3, 5, 100
fizzbuzz(3, 5, 100)
-fizzbuzz(5, 8, 400)
\ No newline at end of file
+#calls fizzbuzz method with values 5, 8, 400
+fizzbuzz(5, 8, 400)
diff --git a/final_prep/mod_zero_hero.rb b/final_prep/mod_zero_hero.rb
index 35eb2cdac..f1d1540a6 100644
--- a/final_prep/mod_zero_hero.rb
+++ b/final_prep/mod_zero_hero.rb
@@ -1,46 +1,78 @@
# Challenge - See if you can follow the instructions and complete the exercise in under 30 minutes!
# Declare two variables - hero_name AND special_ability - set to strings
-
+hero_name = "Procrastigal"
+special_ablitiy = "time manipulation"
# Declare two variables - greeting AND catchphrase
# greeting should be assigned to a string that uses interpolation to include the hero_name
# catchphrase should be assigned to a string that uses interpolation to include the special_ability
-
+greeting = "Never fear, #{hero_name} will be here."
+catchphrase = "Saving the world eventually with #{special_ablitiy}!"
# Declare two variables - power AND energy - set to integers
-
+power = 60
+energy = 80
# Declare two variables - full_power AND full_energy
# full_power should multiply your current power by 500
# full_energy should add 150 to your current energy
-
+full_power = power * 500
+full_energy = energy + 150
# Declare two variables - is_human and identity_concealed - assigned to booleans
-
+is_human = true
+identity_concealed = false
# Declare two variables - arch_enemies AND sidekicks
# arch_enemies should be an array of at least 3 different enemy strings
# sidekicks should be an array of at least 3 different sidekick strings
+arch_enemies = ["Deadliner", "Distracto Dude", "Thanos"]
+sidekicks = ["CreativiTia", "Last Minute Lad", "Greg"]
# Print the first sidekick to your terminal
-
+puts sidekicks.first
# Print the last arch_enemy to the terminal
-
+puts arch_enemies.last
# Write some code to add a new arch_enemy to the arch_enemies array
+arch_enemies[3] = "TimeSlip"
# Print the arch_enemies array to terminal to ensure you added a new arch_enemey
-
+puts arch_enemies
# Remove the first sidekick from the sidekicks array
-
+sidekicks.shift
# Print the sidekicks array to terminal to ensure you added a new sidekick
-
+puts sidekicks
# Create a function called assess_situation that takes three arguments - danger_level, save_the_day, bad_excuse
# - danger_level should be an integer
-# - save_the_day should be a string a hero would say once they save the day
+# - save_the_day should be a string a hero would say once they save the day
# - bad_excuse should be a string a hero would say if they are too afraid of the danger_level
+def assess_situation(danger_level, save_the_day, bad_excuse)
+puts danger_level, save_the_day, bad_excuse
+
+end
+
# Your function should include an if/else statement that meets the following criteria
# - Danger levels that are above 50 are too scary for your hero. Any danger level that is above 50 should result in printing the bad_excuse to the terminal
# - Anything danger_level that is between 10 and 50 should result in printing the save_the_day string to the terminal
# - If the danger_level is below 10, it means it is not worth your time and should result in printing the string "Meh. Hard pass." to the terminal.
-
+def assess_situation(danger_level, save_the_day, bad_excuse)
+
+
+if danger_level > 50
+ puts bad_excuse
+elsif
+ danger_level > 10 && danger_level < 50
+ puts save_the_day
+else
+ danger_level < 10
+ puts "Meh. Hard Pass."
+ end
+end
+
+bad_excuse = "When the threat is too great, I must procrastinate."
+save_the_day = "Down to the wire, I'm the best hero to hire."
+
+puts assess_situation(60, save_the_day, bad_excuse)
+ puts assess_situation(40, save_the_day, bad_excuse)
+ puts assess_situation(2, save_the_day, bad_excuse)
#Test Cases
announcement = 'Never fear, the Courageous Curly Bracket is here!'
excuse = 'I think I forgot to lock up my 1992 Toyota Coralla. Be right back.'
@@ -55,17 +87,27 @@
# - citiesDestroyed (array)
# - luckyNumbers (array)
# - address (hash with following key/values: number , street , state, zip)
-
+scary_monster = {
+ "name" => "BoogeyBoo",
+ "smell" => "Strong",
+ "weight" => 2000,
+ "citiesDestroyed" => ['McCordsville', 'Fort Collins', 'Dallas'],
+ "luckyNumbers" => [10, 4, 85],
+ "address" => {"number" => 1313, "street" => "Wazee St.", "state" => "CO", "zip" => 80205
+ }
+
+}
+puts scary_monster
# Create a new class called SuperHero
# - Your class should have the following DYNAMIC values
-# - name
+# - name
# - super_power
-# - age
+# - age
# - Your class should have the following STATIC values
# - arch_nemesis, assigned to "The Syntax Error"
# - power_level = 100
-# - energy_level = 50
+# - energy_level = 50
# - Create the following class methods
# - say_name, should print the hero's name to the terminal
@@ -74,11 +116,40 @@
# - Create 2 instances of your SuperHero class
+class SuperHero
+
+ def initialize(name, super_power, age)
+ @name = name
+ @super_power = super_power
+ @age = age
+ end
+
+ def initalize(arch_nemesis, power_level, energy_level)
+ @ARCH_NEMESIS = "The Syntax Error"
+ @POWER_LEVEL = 100
+ @ENERGY_LEVEL = 50
+ end
+
+ def say_name
+ puts "The hero's name is #{@name}."
+end
+ def maximize_energy
+ puts "Energy level increased to #{20 * 50}!"
+ end
+ def gain_power
+ () + POWER_LEVEL
+ end
+end
+thor = SuperHero.new("Thor", "Lightning and more", "200lbs")
+puts thor.say_name
+puts thor.maximize_energy
# Reflection
# What parts were most difficult about this exerise?
+# I struggled with class constants and how to define and if - statment in my assess_situation function
# What parts felt most comfortable to you?
+#I'm familar with the concpets I am still working on mastering them
# What skills do you need to continue to practice before starting Mod 1?
-
+# I need to continue practice with accessor methods and instance methods.
diff --git a/section1/ex1.rb b/section1/ex1.rb
new file mode 100644
index 000000000..98c956874
--- /dev/null
+++ b/section1/ex1.rb
@@ -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.'
diff --git a/section1/ex2.rb b/section1/ex2.rb
new file mode 100644
index 000000000..872e3eda5
--- /dev/null
+++ b/section1/ex2.rb
@@ -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."
diff --git a/section1/ex3.rb b/section1/ex3.rb
new file mode 100644
index 000000000..30c588e9b
--- /dev/null
+++ b/section1/ex3.rb
@@ -0,0 +1,23 @@
+puts "I will now count my chickens:"
+
+puts "Hens #{25 + 30 / 6}" # adds 25 and 30 then divides by 6
+puts "Roosters #{100 - 25 * 3 % 4}" # Subtracts 25 from 100 the multiplies by 3
+
+puts "Now I will count the eggs:" #string
+
+puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 # computation
+
+puts "Is it true that 3 + 2 < 5 - 7?" # string
+
+puts 3 + 2 < 5 -7 # < returns false
+
+puts "What is 3 + 2? #{3 + 2}" # string and computation
+puts "What is 5 - 7? #{5 - 7}" # string and computation
+
+puts "Oh that's why it's false." # string
+
+puts "How about some more" # string
+
+puts "Is it greater? #{5 > -2}" #returns true
+puts "Is it greater or equal? #{5 >= -2}" #returns true
+puts "Is it less or equal? #{5 <= -2}" # returns false
diff --git a/section1/ex4.rb b/section1/ex4.rb
new file mode 100644
index 000000000..de0e30596
--- /dev/null
+++ b/section1/ex4.rb
@@ -0,0 +1,16 @@
+cars = 100 # defines number of cars
+space_in_a_car = 4.0 # defines number people that fit in each car
+drivers = 30 # defines number of drivers
+passengers = 90 # defines number of passengers
+cars_not_driven = cars - drivers #computation for inactive cars
+cars_driven = drivers #computation for number of active cars
+carpool_capacity = cars_driven * space_in_a_car # computation for space alotment in cars driven
+average_passengers_per_car = passengers / cars_driven # computation for finding average number of passengers per car 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."
diff --git a/section1/ex5.rb b/section1/ex5.rb
new file mode 100644
index 000000000..cc50cc18c
--- /dev/null
+++ b/section1/ex5.rb
@@ -0,0 +1,21 @@
+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_km = weight / 2.205
+
+puts "Let's talk about my #{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 "He's #{height_in_cm} in centimeters."
+puts "He's #{weight_in_km} in Kilograms."
diff --git a/section1/ex6.rb b/section1/ex6.rb
new file mode 100644
index 000000000..d6f35c5d4
--- /dev/null
+++ b/section1/ex6.rb
@@ -0,0 +1,23 @@
+types_of_people = 10 #declaring var
+x = "There are #{types_of_people} types of people." # declaring var
+binary = "binary" # declaring var
+do_not = "don't" # decalring var
+y = "Those who know #{binary} and those who #{do_not}." # string within string
+
+puts x # prints string
+puts y # prints string
+
+puts "I said: #{x}." #prints string within string
+puts "I also said: '#{y}'." # prints string within string
+
+hilarious = false #declare var
+joke_evaluation = "Isn't that joke so funny?! #{hilarious}" #string within string
+
+puts joke_evaluation #prints string
+
+w = "This is the left side of..." # declares var
+e = "a string with a right side." # declares var
+
+puts w + e # prints vars to create long string
+q = 'is this a string'
+puts q
diff --git a/section1/ex7.rb b/section1/ex7.rb
new file mode 100644
index 000000000..3cb96f6ed
--- /dev/null
+++ b/section1/ex7.rb
@@ -0,0 +1,15 @@
+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 "Whats your sign? "
+horoscope = gets.chomp
+print "Do you believe in it? "
+y_n = gets.chomp
+
+puts "A #{horoscope} would say #{y_n}!"
diff --git a/section1/exercises/booleans.rb b/section1/exercises/booleans.rb
index d3216d9d5..d4c1ebd40 100644
--- a/section1/exercises/booleans.rb
+++ b/section1/exercises/booleans.rb
@@ -9,7 +9,8 @@
p 7 > 2
# YOU DO: log to the console the result of "hello" is equal to "Hello":
-
+puts "hello" == "Hello"
# YOU DO: log to the console the result of 3 is not equal to 4:
-
+puts 3 != 4
# YOU DO: log to the console the result of 4 is less than or equal to 5:
+puts 4 <= 5
diff --git a/section1/exercises/interpolation.rb b/section1/exercises/interpolation.rb
index 2988c5181..965d5a55a 100644
--- a/section1/exercises/interpolation.rb
+++ b/section1/exercises/interpolation.rb
@@ -15,16 +15,20 @@
speedy = "quick red fox"
slow_poke = "lazy brown dog"
-p # YOUR CODE HERE
+puts "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
+puts "In a predictable result, the #{slow_poke} beat the #{speedy}!"
# YOU DO:
# Declare three variables, name/content/data type of your choice. Think carefully about what you name the variables. Remember, the goal is to be concise but descriptive (it's a hard balance!) Then, log out ONE sentence that incorporates all THREE variables.
+author = " - Anais Nin"
+not_see = "We do not see things as they are, "
+see = "we see things as we are."
+puts "#{not_see}#{see} #{author}"
diff --git a/section1/exercises/loops.rb b/section1/exercises/loops.rb
index e8e69523e..2a56daf11 100644
--- a/section1/exercises/loops.rb
+++ b/section1/exercises/loops.rb
@@ -10,13 +10,18 @@
# 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
# Write code that prints the result of 5 + 7 a total of 9 timees
# YOUR CODE HERE
+9.times do
+ p 5 + 7
+end
diff --git a/section1/exercises/numbers.rb b/section1/exercises/numbers.rb
index 91435ffb2..958efcacc 100644
--- a/section1/exercises/numbers.rb
+++ b/section1/exercises/numbers.rb
@@ -3,14 +3,14 @@
# file by entering the following command in your terminal:
# `ruby section1/exercises/numbers.rb`
-# Example: Write code that prints the result of the sum of 2 and 2:
-p 2 + 2
+# Example: Write code that prints the result of the sum of 2 and 2
+puts 2 + 2
# Write code that prints the result of 7 subtracted from 83:
-p #YOUR CODE HERE
+puts 83 - 7
# Write code that prints the result of 6 multiplied by 53:
-# YOUR CODE HERE
+ puts 6 * 53
# Write code that prints the result of the modulo of 10 into 54:
-# YOUR CODE HERE
+puts 10 % 54
diff --git a/section1/exercises/strings.rb b/section1/exercises/strings.rb
index b514a5a63..b4453ab15 100644
--- a/section1/exercises/strings.rb
+++ b/section1/exercises/strings.rb
@@ -4,12 +4,13 @@
# `ruby section1/exercises/strings.rb`
# Example: Write code that prints your name to the terminal:
-p "Alan Turing"
+puts "Alicia Watt"
# Write code that prints `Welcome to Turing!` to the terminal:
-p #YOUR CODE HERE
+puts "Welcome to Turing!"
# Write code that prints `99 bottles of pop on the wall...` to the terminal:
-# YOUR CODE HERE
+puts "99 bottles of pop on the wall...."
-# Write out code to log one line from your favorite song or movie.
\ No newline at end of file
+# Write out code to log one line from your favorite song or movie.
+puts "I'm in a glass case of emotion!"
diff --git a/section1/exercises/variables.rb b/section1/exercises/variables.rb
index d765e886a..b404cbf9a 100644
--- a/section1/exercises/variables.rb
+++ b/section1/exercises/variables.rb
@@ -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 section1/exercises/variables.rb`
# Example: Write code that saves your name to a variable and
@@ -11,38 +11,54 @@
# 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
+puts 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
+dobby_warning = "Harry Potter must not return to Hogwarts!"
+puts dobby_warning
# Write code that adds 2 to the `students` variable and
# prints the result:
students = 22
-# YOUR CODE HERE
+more_students = students + 2
+puts more_students
p students
# Write code that subracts 2 from the `students` variable and
# prints the result:
-# YOUR CODE HERE
+less_students = students - 2
+puts less_students
p students
# YOU DO:
-# Declare three variables, named `first_name`, `is_hungry` and `number_of_pets`.
+# Declare three variables, named `first_name`, `is_hungry` and `number_of_pets`.
# Store the appropriate data types in each.
# print all three variables to the terminal.
+first_name = "Alicia"
+is_hungry = "hungrier than a tic on a teddybear!"
+number_of_pets = 2
-# IN WORDS:
-# How did you decide to use the data type you did for each of the three variables above?
+puts "Hi my name is #{first_name}. I have #{number_of_pets} dogs and they are #{is_hungry} "
+# IN WORDS:
+# How did you decide to use the data type you did for each of the three variables above?
# Explain.
+# first_name is easiest to write as a string because it's a word.
+#I chose a string for is_hungry to convey a longer statment about hunger.
+# I chose a number to reprsent number_of_pets to convey the number of pets
+
# YOU DO:
# Re-assign the values to the three variables from the previous challenge to different values (but same data type).
# print all three variables to the terminal.
+first_name = "Al"
+is_hungry = "too full to function"
+number_of_pets = 4
+
+puts "#{first_name} just fed their #{number_of_pets} cats and they are #{is_hungry}!"
# YOU DO:
@@ -50,10 +66,11 @@
healthy_snacks = 6;
junk_food_snacks = 8;
+puts "The total number of snacks is #{healthy_snacks + junk_food_snacks}"
#-------------------
# FINAL CHECK
#-------------------
-# Did you run this file in your terminal to make sure everything printed out to the terminal
- # as you would expect?
\ No newline at end of file
+# Did you run this file in your terminal to make sure everything printed out to the terminal
+ # as you would expect?
diff --git a/section1/reflection.md b/section1/reflection.md
index 7ce0895a6..487005098 100644
--- a/section1/reflection.md
+++ b/section1/reflection.md
@@ -1,19 +1,43 @@
## Section 1 Reflection
1. How did the SuperLearner Article resonate with you? What from this list do you already do? Want to start doing or do more of? Is there anything not on this list, that you would add to it?
+I enjoyed the SuperLearner Article. I already view learning as a process that requires a lot of reading and growth mindset to keep pushing yourself to grow. I will start utilizing the short breaks to help maintain focus and help with retention. I would add in the description of taking care of your brain that meditation has been shown to help with cognitive function as another way to take care of the brain.
1. How would you print the string `"Hello World!"` to the terminal?
+``` ruby
+puts "Hello World!"
+```
1. What character is used to indicate comments in a ruby file?
+to indicate comments use # hash is used to denote a comment
1. Explain the difference between an integer and a float?
+an **integer** is a whole number and a **float** uses decimals
1. In the space below, create a variable `animal` that holds the string `"zebra"`
+``` ruby
+animal = "zebra"
+```
1. How would you print the string `"zebra"` using the variable that you created above?
+``` ruby
+puts animal
+```
1. What is interpolation? Use interpolation to print a sentence using the variable `animal`.
+interpolation is when you create variables (placeholders) with specific values yielding a result in which the placeholders are replaced with their corresponding values.
+
+``` ruby
+puts "Is a #{animal} black with white stripes or white with black stripes."
+```
+
1. What method is used to get input from a user?
+``` ruby
+gets.chomp
+```
+1. Name and describe two common string methods:
+
+**.length** tells you how many characters (including spaces ) are in a string
-1. Name and describe two common string methods:
\ No newline at end of file
+**. split** breaks the string into words and returns as an array of those words.
diff --git a/section2/exercises/ex18.rb b/section2/exercises/ex18.rb
new file mode 100644
index 000000000..87f6261aa
--- /dev/null
+++ b/section2/exercises/ex18.rb
@@ -0,0 +1,27 @@
+# Names, Variables, Code, Functions
+
+#this one is like your scripts with ARGV
+def print_two(*args)
+ argl, arg2 = args
+ puts "argl: #{argl}, arg2: #{arg2}"
+end
+
+#ok, that *args is actually pointless, we can just do this
+def print_two_again(argl, arg2)
+ puts "argl: #{argl}, arg2: #{arg2}"
+end
+
+#this just takes one argument
+def print_one(argl)
+ puts "argl: #{argl}"
+end
+
+#this just takes no arguments
+def print_none()
+ puts "I got nothin'."
+end
+
+print_two("Zed" , "Shaw")
+print_two_again("Zed" , "Shaw")
+print_one("First!")
+print_none()
diff --git a/section2/exercises/ex19.rb b/section2/exercises/ex19.rb
new file mode 100644
index 000000000..87e051bbb
--- /dev/null
+++ b/section2/exercises/ex19.rb
@@ -0,0 +1,26 @@
+#Functions and variables
+#defines the method
+def cheese_and_crackers(cheese_count, boxes_of_crackers)
+ # prints the cheese count
+ puts "You have #{cheese_count} cheeses!"
+ #prints the boxes of crackers count
+ puts "You have #{boxes_of_crackers} boxes of crackers"
+ puts "Man that's enough for a party!"
+ puts "Get a blanket.\n"
+end
+#prints the method with numbers directly
+puts "We can just give the function numbers directly:"
+cheese_and_crackers(20, 30)
+# prints using variables instead
+puts "OR, we can use variables from our script:"
+amount_of_cheese = 10
+amount_of_crackers = 50
+# method uses variables to define it
+cheese_and_crackers(amount_of_cheese, amount_of_crackers)
+# uses math to give value to the function or method
+puts "We can even do math inside too:"
+cheese_and_crackers(10 + 20, 5 + 6)
+
+puts "And we can combine the two, variables and math:"
+# combines math and variables to give the function its value
+cheese_and_crackers(amount_of_cheese + 100, amount_of_crackers + 1000)
diff --git a/section2/exercises/ex21.rb b/section2/exercises/ex21.rb
new file mode 100644
index 000000000..a75c21402
--- /dev/null
+++ b/section2/exercises/ex21.rb
@@ -0,0 +1,37 @@
+# Functions cna return something
+def add(a, b)
+ puts "ADDING #{a} + #{b}"
+ return a + b
+ end
+
+ def subtract(a, b)
+ puts "SUBTRACTING #{a} - #{b}"
+ return a - b
+ end
+
+ def multiply(a, b)
+ puts "Multiplying #{a} * #{b}"
+ return a * b
+ end
+
+ def divide(a, b)
+ puts "DIVIDING #{a} / #{b}"
+ return a / b
+ end
+
+ puts "Let's do some math with just functions!"
+
+ age = add(30, 5)
+ height = subtract(78, 4)
+ weight = multiply(90, 2)
+ iq = divide(100, 2)
+
+ puts "Age: #{age}, Height: #{height}, Weight: #{weight}, IQ: #{iq}"
+
+ #puzzle for extra credit
+
+ puts "Here is a puzzle."
+
+ what = add(age, subtract(height, multiply(weight, divide(iq, 2))))
+
+ puts "That becomes #{what}. Can you do it by hand?"
diff --git a/section2/exercises/ex29.rb b/section2/exercises/ex29.rb
new file mode 100644
index 000000000..ce1bb5dd2
--- /dev/null
+++ b/section2/exercises/ex29.rb
@@ -0,0 +1,47 @@
+#What If
+people = 20
+cats = 30
+dogs = 15
+
+if people < cats
+ puts "Too many cats! The world is doomed!"
+end
+
+if people > cats
+ puts "Not many cats! The world is saved!"
+end
+
+if people < dogs
+ puts "The world is drooled on!"
+end
+
+if people > dogs
+ puts "The world is dry!"
+end
+
+dogs += 5
+
+if people >= dogs
+ puts "People are greater than or equal to dogs."
+end
+
+if people <= dogs
+ puts "People are less than or equal to dogs."
+end
+
+if people == dogs
+ puts "People are dogs"
+end
+
+#study drills
+#Q:What do you think the if does to the code under it?
+#A: The if creates a conditonal creating a decison making statment that will execute on a set of code depending on which condition is met.
+
+#Q: Why does the code und the if need to be indented two spaces?
+#A: It creates a block of code and end with "end". Indentation allows for code managability. It's easier to read.
+
+#Q: What happens if it isn't indented?
+#A: Makes it harder to read but doesn't impact how the code runs.
+
+#Q:What happens if you change the intial values for people, cats, and dogs?
+#A It changes the code executed because the conditons met have changed : )
diff --git a/section2/exercises/ex30.rb b/section2/exercises/ex30.rb
new file mode 100644
index 000000000..e6b0a0957
--- /dev/null
+++ b/section2/exercises/ex30.rb
@@ -0,0 +1,31 @@
+#Else and if
+people = 30
+cars = 40
+trucks = 15
+# will print "We should take the cars because cars (40) are greater than people (30)"
+if cars > people
+ puts "We should take the cars."
+ #will not print because cars art greater than people
+elsif cars < people
+ puts "We should not take the cars."
+else
+ #Will not print because first conditional is true
+ puts "We can't decide."
+end
+#Will not print because trucks are < cars
+if trucks > cars
+ puts "That's too many trucks."
+ #Will print becuase trucks < cars
+elsif trucks < cars
+ puts "Maybe we could take the trucks."
+else
+ #will not print because trucks < is true
+ puts "We still can't decide."
+end
+# will print because people > trucks
+if people > trucks
+ puts "Alright, let's just take the trucks."
+else
+ #will not print becuse previous statment is true
+ puts "Fine, let's stay home then."
+end
diff --git a/section2/exercises/ex31.rb b/section2/exercises/ex31.rb
new file mode 100644
index 000000000..9904d59d6
--- /dev/null
+++ b/section2/exercises/ex31.rb
@@ -0,0 +1,40 @@
+# Making Decisions
+puts "You enter a dark room with two doors. Do you go through the door #1 or door #2?"
+
+print "> "
+door = $stdin.gets.chomp
+
+if door == "1"
+ puts "There's a giant bear here eating a cheese cake. What do you do?"
+ puts "1. Take the cake."
+ puts "2. Scream at the bear."
+
+ print " > "
+ bear = $stdin.gets.chomp
+
+ if bear == "1"
+ puts "The bear eats your face off. Good job!"
+ elsif bear == "2"
+ puts "The bear eats your legs off. Good Job!"
+ else
+ puts "Well doing %s is probably better. Bear runs away." % bear
+ end
+
+elsif door == "2"
+ puts "You stare into the endless abyss at Cthulhu's retina."
+ puts "1. Blueberries"
+ puts "2. Yellow jacket clothespins."
+ puts "3. Understanding revovers yelling melodies."
+
+ print "> "
+ insanity = $stdin.gets.chomp
+
+ if insanity == "1" || insanity == "2"
+ puts "Your body surivies powered by a mind of jello. Good job!"
+ else
+ puts "The insanity rots your eyes into a pool of much. Good job!"
+ end
+
+else
+ puts "You stumble around and fall on a knife and die. Good job!"
+end
diff --git a/section2/exercises/if_statements.rb b/section2/exercises/if_statements.rb
index f29c45cdd..935481c00 100644
--- a/section2/exercises/if_statements.rb
+++ b/section2/exercises/if_statements.rb
@@ -3,14 +3,14 @@
# file by entering the following command in your terminal:
# `ruby section2/exercises/if_statements.rb`
-# Example: Using the weather variable below, write code that decides
+# Example: Using the weather variable below, write code that decides
# what you should take with you based on the following conditions:
# if it is sunny, print "sunscreen"
# if it is rainy, print "umbrella"
# if it is snowy, print "coat"
# if it is icy, print "yak traks"
- weather = 'snowy'
+ weather = 'icy'
if weather == 'sunny'
p "sunscreen"
@@ -35,21 +35,24 @@
# Right now, the program will print
# out both "I have enough money for a gumball" and
-# "I don't have enough money for a gumball". Write a
+# "I don't have enough money for a gumball". Write a
# conditional statement that prints only one or the other.
# Experiment with manipulating the value held within num_quarters
# to make sure both conditions can be achieved.
-num_quarters = 0
+num_quarters = 2
-puts "I have enough money for a gumball"
-puts "I don't have enough money for a gumball"
+if num_quarters >= 2
+ puts "I have enough money for a gumball"
+else num_quarters < 2
+ puts "I don't have enough money for a gumball"
+end
#####################
# Using the variables defined below, write code that will tell you
-# if you have the ingredients to make a pizza. A pizza requires
+# if you have the ingredients to make a pizza. A pizza requires
# at least two cups of flour and sauce.
# You should be able to change the variables to achieve the following outputs:
@@ -61,5 +64,11 @@
# Experiment with manipulating the value held within both variables
# to make sure all above conditions output what you expect.
-cups_of_flour = 1
-has_sauce = true
+cups_of_flour = 5
+has_sauce = false
+
+if cups_of_flour >= 2 && has_sauce == true
+ puts "I can make pizza"
+else
+ puts "I cannot make pizza"
+end
diff --git a/section2/exercises/methods.rb b/section2/exercises/methods.rb
index f2517f1b3..04258cadf 100644
--- a/section2/exercises/methods.rb
+++ b/section2/exercises/methods.rb
@@ -12,19 +12,60 @@ def print_name
# Write a method that takes a name as an argument and prints it:
def print_name(name)
- # YOUR CODE HERE
+puts "Name: #{name}"
end
print_name("Albus Dumbledore")
-# Write a method that takes in 2 numbers as arguments and prints
+# Write a method that takes in 2 numbers as arguments and prints
# their sum. Then call your method three times with different arguments passed in:
# YOUR CODE HERE
+def sum(a, b)
+ puts "Sum total: #{a} + #{b} = #{10 + 20}"
+
+end
+
+sum(10,20)
+
+a=10
+b= 20
+sum(b, a)
+
+sum(a - 5, b + 5)
+
+def add(num)
+ num + num
+end
+
+puts add(10)
+
+
+# Write a method that takes in two strings as arguments and prints
+# a concatenation of those two strings. Example: The arguments could be
+# (man, woman) and the end result might output: "When Harry Met Sally".
+# Then call your method three times with different arguments passed in.
+
+def wizard(hagrid, harry)
+puts "Hagrid: #{hagrid} Harry: #{harry}"
+end
+
+wizard("Yer a wizard Harry.", "I'm a what?")
+
+
+hagrid = "Yer a wizard Harry."
+harry = "I'm a what?"
+
+wizard(hagrid, harry)
+
+hagrid = "Yer a wizard Harry."
+
+wizard(hagrid, "I'm a what?")
+
+
+
+
+
-# Write a method that takes in two strings as arguments and prints
-# a concatenation of those two strings. Example: The arguments could be
-# (man, woman) and the end result might output: "When Harry Met Sally".
-# Then call your method three times with different arguments passed in.
#-------------------
@@ -38,4 +79,5 @@ def print_name(name)
# What did you name each parameter, and why?
# EXPLAIN:
-
+ #I named the function "wizard" because the term wizard connects to the scene and is associased with Harry potter.
+ #I named each parameter "hagrid" and "harry" each parameter connects to the dialog to be printed hagrid's line and harry's line
diff --git a/section2/exercises/say.rb b/section2/exercises/say.rb
new file mode 100644
index 000000000..c93aeace5
--- /dev/null
+++ b/section2/exercises/say.rb
@@ -0,0 +1,28 @@
+def say(words='hello')
+ puts words + '.'
+end
+
+say()
+say("hi")
+say("how are you")
+say("I'm fine")
+
+a = 5
+
+def some_method
+ a = 3
+end
+
+puts a
+
+#Method invocation with a block
+
+[1, 2, 3].each do |num|
+ puts num
+end
+
+#Method definition
+
+def print_num(num)
+ puts num
+end
diff --git a/section2/reflection.md b/section2/reflection.md
index 49f0606df..d9aba4cbc 100644
--- a/section2/reflection.md
+++ b/section2/reflection.md
@@ -1,29 +1,79 @@
## Section 2 Reflection
1. Regarding the blog posts in Part A, how do you feel about asking questions? Do you tend to ask them too soon, or wait too long, or somewhere in between?
+ I think this article is a great reminder that silly questions are a part of learning. It's important to give yourself a time limit to solve things independently because its possible asking questions will help you refine how you self solve problems in the future and save you time by seeking help from a peer or someone with more experience.
+ I find that I have a tendency to spend too much time trying to solve a problem independently before I ask questions. I'm working on sticking to a time limit on that and asking questions before I've spent far to long on my own search.
+
### If Statements
1. What is a conditional statement? Give three examples.
+ A conditional statement is a way for a computer to make decisions based on conditions. The conditional statement evaluates to either "true" or "false".
+ ..* If I'm in Hawaii then it is vacation.
+ ..* If password is incorrect then access is denied
+ ..* If password is correct then access is granted
1. Why might you want to use an if-statement?
+ an if-statement is a decision making statement based on specific criteria. Using if statements allows for your script to decide things which is useful for evaluating input and returning responding output.
1. What is the Ruby syntax for an if statement?
+```ruby
+marshmallows = 10
+grahams = 20
+chocolate_bars = 10
+
+if marshmallows == chocolate_bars
+ puts "perfect ingredient ratio"
+end
+```
+
1. How do you add multiple conditions to an if statement?
+ You can use && to add multiple conditions to an if statement.
1. Provide an example of the Ruby syntax for an if/elsif/else statement:
+```ruby
+ weather = "snowy"
+
+if weather == "sunny"
+ puts " grab sunglasses"
+elsif weather == "windy"
+ puts "fly kite"
+else weather == "snowy"
+ puts "grab skis"
+end
+```
1. Other than an if-statement, can you think of any other ways we might want to use a conditional statement?
+ You could display a conditional expression. It would evaluate to either true or false without using and if-statement.
### Methods
1. In your own words, what is the purpose of a method?
+ A method is a block of code that will preform specific tasks that you can call from different parts of the program.
+
1. Create a method named `hello` that will print `"Sam I am"`.
+ ``` ruby
+ def hello
+ puts "Sam I am"
+ end
+ ```
+
1. Create a method named `hello_someone` that takes an argument of `name` and prints `"#{name} I am"`.
+``` ruby
+def hello_someone
+ puts "#{name} I am"
+end
+```
+
1. How would you call or execute the method that you created above?
-1. What questions do you have about methods in Ruby?
\ No newline at end of file
+``` ruby
+ hello_someone("Alicia")
+ ```
+
+1. What questions do you have about methods in Ruby?
+ Why are method and function interchangeable?
diff --git a/section3/ex32.rb b/section3/ex32.rb
new file mode 100644
index 000000000..2ec92fde5
--- /dev/null
+++ b/section3/ex32.rb
@@ -0,0 +1,35 @@
+# Loops and Arrays
+the_count = [ 1, 2, 3, 4, 5]
+fruits = ['apples', 'oranges', 'pears', 'apricots']
+change = [1, 'pennies', 2, 'dimes', 3, 'quarters']
+
+# the first kind of for-loop goes through a list
+# in a more traditonal style found in other languages
+ the_count.each do |the_count|
+ puts "This is count #{the_count}"
+end
+
+#same as above, but in a more Ruby style
+# this and the next one are the preferred
+# way Ruby for-loops are written
+fruits.each do |fruit|
+ puts "A fruit of type: #{fruit}"
+end
+
+# also we can go through mixed lists too
+# note this is yet another style, exactly like above
+# but a different syntax (way to write it
+change.each {|i| puts "I got #{i}"}
+
+# we can also build lists, first start with an empty one
+elements = []
+
+# then use the range operator to do 0 to 5 counts
+(0..5).each do |i|
+ puts "adding #{i} to the list."
+ # pushes the i variable to the *end* of the list
+ elements.push(i)
+end
+
+# now we can print them out # TODO:
+elements.each {|i| puts "Elements was: #{i}"}
diff --git a/section3/ex34.rb b/section3/ex34.rb
new file mode 100644
index 000000000..a84f3ab50
--- /dev/null
+++ b/section3/ex34.rb
@@ -0,0 +1,21 @@
+# Accessing Elemnts of Arrays
+animals = ['bear', 'tiger', 'penguin', 'zebra']
+bear = animals[0]
+
+animals = ['bear', 'ruby', 'peacock', 'kangaroo', 'whale', 'platypus']
+
+"The animal at 1 is the 2nd animal and is a ruby"
+
+"The third (3rd) animal is at 2 and is a peacock"
+
+"The first (1st) andimal is at 0 and is a bear"
+
+"The animal at 3 is the 4th animal is a kangaroo"
+
+"The fifth (5th) animal is at 4 and is whale"
+
+"The animal at 2 is the 3rd animal and is a peacock"
+
+"The sixth (6th) animal is at 5 and is a platypus"
+
+"The animal at 4 is the 5th animal an is whale"
diff --git a/section3/ex39.rb b/section3/ex39.rb
new file mode 100644
index 000000000..3ea2847da
--- /dev/null
+++ b/section3/ex39.rb
@@ -0,0 +1,123 @@
+# Hashes, oh lovely hashes
+
+#create a mapping of state to abbreviation
+states = {
+ 'Oregon' => 'OR',
+ 'Florida' => 'FL',
+ 'California' => 'CA',
+ 'New York' => 'NY',
+ 'Michigan' => 'MI',
+
+}
+
+#create a basic set of states and some citites in them
+cities = {
+ 'CA' => 'San Francisco',
+ 'MI' => 'Detroit',
+ 'FL' => 'Jacksonville'
+}
+
+#add some more cities
+cities['NY'] = 'New York'
+cities['OR'] = 'Portland'
+
+#put out some cities
+puts '-' * 10
+puts "NY State has: #{cities['NY']}"
+puts "OR State has: #{cities["OR"]}"
+
+#puts some states
+puts '-' * 10
+puts "Michigan's abbreviation is #{states['Michigan']}"
+puts "Florida's abbreiation is #{states['Florida']}"
+
+#do it by using the state then cities dict
+puts '-' * 10
+puts "Michigan has: #{cities[states['Michigan']]}"
+puts "Florida has: #{cities[states['Florida']]}"
+
+# puts every state abbreviation
+puts "-" * 10
+states.each do |state, abbrev|
+ puts "#{state} is abbreviated #{abbrev}"
+end
+
+# puts every city in state
+puts '-' * 10
+cities.each do |abbrev, city|
+ puts "#{abbrev} has the city #{city}"
+end
+
+# now do both at the same time
+puts '-' * 10
+states.each do |state, abbrev|
+ city = cities[abbrev]
+ puts "#{state} is abbreviated #{abbrev} and had a city #{city}"
+end
+
+puts '-' * 10
+# by default ruby say "nil" when something isn't there
+state = states['Texas']
+
+if !state
+ puts "Sorry, no Texas."
+end
+
+#default values using || = with the nil result
+city = cities['TX']
+city ||= 'Does Not Exist'
+puts "The city for the state 'TX' is: #{city}"
+
+# Arrays
+#?> things = ['a', 'b', 'c', 'd']
+#=> ["a", "b", "c", "d"]
+#>> puts things[1]
+#b
+#=> nil
+#>> things[1] = 'z'
+#"z"
+#>> puts things[1]
+#z
+#=> nil
+#>> things
+#=> ["a", "z", "c", "d"]
+
+# Hashes
+
+#?> stuff = {'name' => 'Zed', 'age' => 39, 'height' => 6 * 12 + 2}
+#=> {"name"=>"Zed", "age"=>39, "height"=>74}
+#>> puts stuff['name']
+#Zed
+#=> nil
+#>> puts stuff['age']
+#39
+#=> nil
+#>> puts stuff['height']
+#74
+#=> nil
+#>> stuff['city'] = "San Francisco"
+#=> "San Francisco"
+#>> print stuff['city']
+#San Francisco=> nil
+
+#?> stuff[1] = "Wow"
+#=> "Wow"
+#>> stuff[2] = "Neato"
+#=> "Neato"
+#>> puts stuff[1]
+#Wow
+#=> nil
+#>> puts stuff[2]
+#Neato
+#=> nil
+#>> stuff
+#=> {"name"=>"Zed", "age"=>39, "height"=>74, "city"=>"San Francisco", 1=>"Wow", 2=>"Neato"}
+
+#?> stuff.delete('city')
+#=> "San Francisco"
+#>> stuff.delete(1)
+#=>"Wow"
+#>>stuff.delete(2)
+#=>"Neato"
+#>> stuff
+#=> {"name"=>"Zed", "age"=>39, "height"=>74}
diff --git a/section3/exercises/arrays.rb b/section3/exercises/arrays.rb
index f710c6000..41f41b9e6 100644
--- a/section3/exercises/arrays.rb
+++ b/section3/exercises/arrays.rb
@@ -14,51 +14,71 @@
# EXAMPLE: write code below that will print an array of animals.
# Store the array in a variable.
-animals = ["Zebra", "Giraffe", "Elephant"];
+animals = [" Zebra", "Giraffe", "Elephant"];
print animals
# EXAMPLE: Write code below that will print "Zebra" from the animals array
-# YOUR CODE HERE
-print animals[0]
+
+puts animals[0]
# YOU DO: Write code below that will print the number of elements in array of
# animals from above.
+animals.each do |animals|
+ puts "A type of animal: #{animals}"
+end
+
+
# YOU DO: Write code that will reassign the last item in the animals
# array to "Gorilla"
-
+animals[animals.index("Elephant")] = "Gorilla"
+puts animals[2]
+animals.each do |animals|
+ puts animals
+end
# YOU DO: Write code that will add a new animal (type of your choice) to position 3.
-
+animals[3] = "Otter"
+puts animals[3]
# YOU DO: Write code that will print the String "Elephant" in the animals array
-
+animals[4] = "Elephant"
+puts animals
#-------------------
# PART 2: Foods: Array Methods
#-------------------
# YOU DO: Declare a variable that will store an an array of at least 4 foods (strings)
-
+food = ["Squash", "Popcorn", "Apples", "Coffee"]
+puts food
# YOU DO: Write code below that will print the number of elements in the array of
# foods from above.
+puts "food count: #{food.count}"
# YOU DO: Write code below that uses a method to add "broccoli" to the foods array and
# print the changed array to verify "broccoli" has been added
-
+food[4] = "Broccoli"
+puts food
# YOU DO: Write code below that removes the last item of food from the foods array and
# print the changed array to verify that item has been removed
+food.pop
+puts food
-# YOU DO: Write code to add 3 new foods to the array.
+# YOU DO: Write code to add 3 new foods to the array.
# There are several ways to do this - choose whichever you'd like!
# Then, print the changed array to verify the new items have been added
+food.push(["Banana", "Gouda", "Wine"])
+puts food
# YOU DO: Remove the food that is in index position 0.
+food.shift
+puts food
#-------------------
# PART 3: Where are Arrays used?
@@ -77,11 +97,9 @@
posts = ["image at beach", "holiday party", "adorable puppy", "video of cute baby"];
# YOU DO: Think of a web application you commonly use. Where do you see LISTS utilized, where arrays
-# may be storing data? Come up with 3 examples - they could be from different web applications or
+# may be storing data? Come up with 3 examples - they could be from different web applications or
# all from the same one.
-# 1:
-# 2:
-# 3:
-
-
+# 1: gmail_folders = ["Inbox", "Starred", "Sent", "Drafts"];
+# 2: pinterest_boards = ["style", "quotes", "design inspo"];
+# 3: spotify_genre = ["Pop", "EDM", "Rap" ];
diff --git a/section3/exercises/hashes.rb b/section3/exercises/hashes.rb
index 9d368c753..3d6a7fa98 100644
--- a/section3/exercises/hashes.rb
+++ b/section3/exercises/hashes.rb
@@ -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 section3/exercises/hashes.rb`
# Example: Write code that prints a hash holding grocery store inventory:
@@ -8,24 +8,36 @@
p foods
# Write code that prints a hash holding zoo animal inventory:
-zoo = #YOUR CODE HERE
+zoo = {koalas: 4, tigers: 2, flamingos: 12, penguins: 20}
p zoo
-# Write code that prints all of the 'keys' of the zoo variable
+# Write code that prints all of the 'keys' of the zoo variable
# you created above:
-# YOUR CODE HERE
+puts '-' * 10
+zoo.each do |animal, value|
+ puts "Each key is #{animal}"
+end
-# Write code that prints all of the 'values' of the zoo variable
+
+# Write code that prints all of the 'values' of the zoo variable
# you created above:
-# YOUR CODE HERE
+puts '-' * 10
+zoo.each do |animal, value|
+ puts "Each value is #{value}"
+end
-# Write code that prints the value of the first animal of the zoo variable
+# Write code that prints the value of the first animal of the zoo variable
# you created above:
-# YOUR CODE HERE
-# Write code that adds an animal to the zoo hash.
+puts zoo.values[0]
+
+# Write code that adds an animal to the zoo hash.
# Then, print the updated hash:
-# YOUR CODE HERE
+zoo ['Otters'] = 8
+puts '-' * 10
+zoo.each do |animal, value|
+ puts "The zoo has #{value}: #{animal}"
+end
#-------------------
@@ -38,17 +50,31 @@
# Declare a variable that stores hash. Each key should be an attribute of an email and each
# value should be some appropriate value for that key. Work to have at least 5 key-value pairs.
-
+ email_components = {
+ 'Sender' => 'Sender@me.com',
+ 'To' => 'Recipient@me.com',
+ 'Subject' => 'What you call your email',
+ 'Body' => 'message you are sending',
+ 'attachment' => 'the files or images you want to connect to your email',
+
+ }
# Write code that prints your email hash to the terminal.
-
-# Write code that prints all of the 'keys' of the email hash
+ puts email_components
+# Write code that prints all of the 'keys' of the email hash
# you created above:
-# YOUR CODE HERE
-# Write code that prints all of the 'values' of the email hash
+puts '-' * 10
+email_components.each do |key, value|
+ puts "Each key is #{key}"
+end
+
+# Write code that prints all of the 'values' of the email hash
# you created above:
-# YOUR CODE HERE
+puts '-' * 10
+email_components.each do |key, value|
+ puts "Each value is #{value}"
+end
#-------------------
@@ -64,7 +90,7 @@
# posts = ["image at beach", "holiday party", "adorable puppy", "video of cute baby"];
-# Frankly, that was a very simplified version of the Array the Instagram developers have
+# Frankly, that was a very simplified version of the Array the Instagram developers have
# written and work with. Still probably slightly simplified as we don't know what their code
# actually looks like, but it may look more like this:
@@ -76,7 +102,7 @@
'timestamp' => "4:37 PM August 13, 2019",
'number_likes' => 0,
'comments' => []
- },
+ },
{
'image_src' => "./images/holiday-party.png",
'caption' => "What a great holiday party omg",
@@ -90,12 +116,35 @@
puts posts[0]
-# The code snippet above shows an Array with 2 elements. Each element in an
-# Object Literal. Each of those Object Literals has 4 key-value pairs. This may LOOK
+# The code snippet above shows an Array with 2 elements. Each element in an
+# Object Literal. Each of those Object Literals has 4 key-value pairs. This may LOOK
# a bit daunting - it's OK! You don't need to be 100% comfortable with this, but it's
# good to have some exposure before going into Mod 1.
-# YOU DO: Create an array of at least 3 EMAIL Object Literals, using the same
+# YOU DO: Create an array of at least 3 EMAIL Object Literals, using the same
# key-value pairs you used in your email Object above.
-# Then, log the email Array to the console.
\ No newline at end of file
+# Then, log the email Array to the console.
+email_components = [
+{
+ 'Sender' => 'Sender@me.com',
+ 'To' => 'Recipient@me.com',
+ 'Subject' => 'What you call your email',
+ 'Body' => 'message you are sending',
+ 'attachment' => 'file.txt',
+},
+{ 'Sender' => 'Sender@gmail.com',
+ 'To' => 'Recipient@gmail.com',
+ 'Subject' => 'Howdy!',
+ 'Body' => 'How are you?',
+ 'attachment' => 'images/emoji.png',
+},
+{ 'Sender' => 'cowboy@me.com',
+ 'To' => 'saddleUp@me.com',
+ 'Subject' => 'Rodeo',
+ 'Body' => 'I have attached your rodeo invitation',
+ 'attachment' => 'images/rodeo.png',
+}
+]
+
+puts email_components
diff --git a/section3/reflection.md b/section3/reflection.md
index cda726fd3..10d47ca8b 100644
--- a/section3/reflection.md
+++ b/section3/reflection.md
@@ -1,17 +1,40 @@
## Section 3 Reflection
1. What are two points from the Growth Mindset article and/or video that either resonated with you, or were brand new to you?
+..1. practicing S.M.A.R.T goals makes breaks coding projects down into manageable sub goals to help you strategize and accomplish work in at timely manner.
+..2.The Zone of Proximal Development was new to me. Solving problems takes place within ones capabilities with some guidance. It's okay to push beyond what you've mastered and to continue pushing incrementally outside of your knowledge depth as you become more proficient because this is how you grow.
1. In which ways do you currently demonstrate a Growth Mindset? In which ways do you _not_?
+..1. I demonstrate Growth Mindset my belief that I can improve and that mistakes are essential to learning.
+..2.I could improve my Growth Mindset by seeking out more challenges as I continue my journey in coding.
1. What is a Hash, and how is it different from an Array?
+... A hash is a collection of key - value pairs. It's like a map that you can use throughout your script. A Hash differes from an Array because Hashes can have arbitrary objects as indexes instead of just integers like you would see in an Array.
1. In the space below, create a Hash stored to a variable named `pet_store`. This hash should hold an inventory of items and the number of that item that you might find at a pet store.
+```ruby
+ pet_store = {fish: 20, treats: 100, hamsters: 15}
+ ```
1. Given the following `states = {"CO" => "Colorado", "IA" => "Iowa", "OK" => "Oklahoma"}`, how would you access the value `"Iowa"`?
+``` ruby
+ puts states.value[1]
+ ```
1. With the same hash above, how would we get all the keys? How about all the values?
+``` ruby
+states.each do |abbrev, state|
+ puts "Each key is #{abbrev}"
+end
+```
+``` ruby
+states.each do |abbrev, state|
+ puts "Each value is #{state}"
+end
+```
1. What is another example of when we might use a hash? In your example, why is a hash better than an array?
+... You could use a hash if you wanted to create an index of facts about a city. A hash is best for this because it can include all data types like integers, strings, arrays, and booleans to index details about the city.
1. What questions do you still have about hashes?
+None that google or my peers haven't been able to answer for me. I'm sure I'll have more after feedback.
diff --git a/section4/exercises/burrito.rb b/section4/exercises/burrito.rb
index 967f68b6c..326bfbc4a 100644
--- a/section4/exercises/burrito.rb
+++ b/section4/exercises/burrito.rb
@@ -1,4 +1,4 @@
-# Add the following methods to this burrito class and
+# Add the following methods to this burrito class and
# call the methods below the class:
# 1. add_topping
# 2. remove_topping
@@ -11,9 +11,44 @@ def initialize(protein, base, toppings)
@base = base
@toppings = toppings
end
-end
+
+ def add_toppings(protein, base, toppings)
+ @protein = protein
+ @base = base
+ @toppings = toppings
+ end
+
+ def remove_topping(protein, base, toppings)
+ @protein = protein
+ @base = base
+ @toppings = toppings
+ end
+
+ def change_protein(protein, base, toppings)
+ @protein = protein
+ @base = base
+ @toppings = toppings
+ end
+
+ end
dinner = Burrito.new("Beans", "Rice", ["cheese", "salsa", "guacamole"])
p dinner.protein
p dinner.base
p dinner.toppings
+
+dinner.add_toppings("Beans" , "Rice" , ["cheese","salsa", "guacamole", "sour cream"])
+p dinner.protein
+p dinner.base
+p dinner.toppings
+
+
+dinner.remove_topping("Beans" , "Rice" , ["cheese","salsa"])
+p dinner.protein
+p dinner.base
+p dinner.toppings
+
+dinner.change_protein("Carnitas", "Rice", ["cheese", "salsa", "guacamole"])
+p dinner.protein
+p dinner.base
+p dinner.toppings
diff --git a/section4/exercises/dog.rb b/section4/exercises/dog.rb
index 03221314d..2abe70da7 100644
--- a/section4/exercises/dog.rb
+++ b/section4/exercises/dog.rb
@@ -1,5 +1,5 @@
# In the dog class below, write a `play` method that makes
-# the dog hungry. Call that method below the class, and
+# the dog hungry. Call that method below the class, and
# print the dog's hunger status.
class Dog
@@ -19,6 +19,10 @@ def bark
def eat
@hungry = false
end
+
+ def play
+ @hungry = true
+ end
end
fido = Dog.new("Bernese", "Fido", 4)
@@ -28,3 +32,5 @@ def eat
p fido.hungry
fido.eat
p fido.hungry
+ fido.play
+ p fido.hungry
diff --git a/section4/exercises/person.rb b/section4/exercises/person.rb
index 2c26e9570..73990ccdb 100644
--- a/section4/exercises/person.rb
+++ b/section4/exercises/person.rb
@@ -1,5 +1,34 @@
-# Create a person class with at least 2 attributes and 2 behaviors.
+# Create a person class with at least 2 attributes and 2 behaviors.
# Call all person methods below the class and print results
# to the terminal that show the methods in action.
# YOUR CODE HERE
+class Person
+ attr_accessor :name, :height
+ def initialize(name, height)
+ @name = name
+ @height = height
+
+ end
+
+ def stats
+ "This is #{name} they are #{height} inches tall."
+ end
+
+ def is_tall
+ puts "Is #{name} tall?"
+ if @height >= 68
+ return true
+ end
+ return false
+ end
+
+end
+
+buddy = Person.new('Buddy', 69)
+puts buddy.stats
+puts buddy.is_tall
+
+todd = Person.new('Todd', 64)
+puts todd.stats
+puts todd.is_tall
diff --git a/section4/exercises/student.rb b/section4/exercises/student.rb
new file mode 100644
index 000000000..a0714572a
--- /dev/null
+++ b/section4/exercises/student.rb
@@ -0,0 +1,15 @@
+class Student
+ attr_accessor :first_name, :last_name, :primary_phone_number
+
+ def introduction(target)
+ puts "Hi, #{target}, I'm #{first_name}!"
+ end
+
+ def favorite_number
+ 7
+ end
+end
+
+frank = Student.new
+frank.first_name = "Frank"
+puts "Frank's favorite number is #{frank.favorite_number}."
diff --git a/section4/reflection.md b/section4/reflection.md
index 68b044b00..4f0489c0f 100644
--- a/section4/reflection.md
+++ b/section4/reflection.md
@@ -1,22 +1,44 @@
## Section 4 Reflection
1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique?
+... It took some adjustment to get used to the flow of the Pomodoro method. The 25 minute span meant that I needed to break up my work into smaller pieces to be able to complete a task during each cycle.
1. Regarding the work you did around setting intentions in Step 1 of the Pomodoro technique - how did that go? Were you surprised by anything (did you find yourself way more focused than you realized, more distracted that you thought you'd be, estimating times accurately or totally off, etc)?
+... I had to adjust my calculation of how long it would take me to accomplish tasks. When I began Pomodoro I underestimated how long it would take me to complete a task so I eventually broke down larger tasks into sub tasks that I could complete in the 25 minute cycles. Once I was able to calibrate my tasks to fit into the 25 minute segments I felt better able to focus on the task in front of me.
1. In your own words, what is a Class?
+... A class is a way represent (through attributes and behaviors) an abstraction of something. An example would be a car. A car can come in many shapes and sizes but you would expect most cars to have wheels, steering wheel, and brakes. You would also expect most cars to behave similarly it can park, stop, and go.
1. What is an attribute of a Class?
+... Attributes are the variables that describe the features of a class.
1. What is behavior of a Class?
+... a behavior is describing the actions a class is capable of.
1. In the space below, create a Dog class with at least 2 attributes and 2 behaviors:
```rb
-
+class Dog
+ attr_reader :name, :breed
+ def initialize(name, breed)
+ @name = name
+ @breed = breed
+ @age = age
+ end
+ def howl
+ p "Aroooo"
+ end
+ def is_puppy
+ puts "Is #{name} a puppy?"
+ if @age <= 1
+ return true
+ end
+ return false
+ end
+ end
```
1. How do you create an instance of a class?
-1. What questions do you still have about classes in Ruby?
\ No newline at end of file
+ object = class.new