From 9ce3f4c2099ba10b24e963492a2250a5e55a0c8c Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 18:33:43 -0600 Subject: [PATCH 01/50] Initial commit --- section1/ex1.rb | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 section1/ex1.rb diff --git a/section1/ex1.rb b/section1/ex1.rb new file mode 100644 index 00000000..ebec88bd --- /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.' From 9bb4b3046b24ae82edd8cefc1b20b5ec591276e4 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 18:35:30 -0600 Subject: [PATCH 02/50] Exercise 2 --- section1/ex2.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 section1/ex2.rb diff --git a/section1/ex2.rb b/section1/ex2.rb new file mode 100644 index 00000000..dffb2b27 --- /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." From 8f9f2f230ce2ab49f89c8988acdd4262dd6d214b Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 18:37:30 -0600 Subject: [PATCH 03/50] Exercise 3 --- section1/ex3.rb | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 section1/ex3.rb diff --git a/section1/ex3.rb b/section1/ex3.rb new file mode 100644 index 00000000..0b7380c6 --- /dev/null +++ b/section1/ex3.rb @@ -0,0 +1,23 @@ +puts "I will now count my chickens:" + +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}" From 4aa5c89857000f1506b3357b6bd4655e77df3c22 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 18:42:27 -0600 Subject: [PATCH 04/50] Exercise 4 --- section1/ex4.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 section1/ex4.rb diff --git a/section1/ex4.rb b/section1/ex4.rb new file mode 100644 index 00000000..979127ae --- /dev/null +++ b/section1/ex4.rb @@ -0,0 +1,16 @@ +cars = 100 +space_in_a_car = 4.0 +drivers = 30 +passengers = 90 +cars_not_driven = cars - drivers +cars_driven = drivers +carpool_capacity = cars_driven * space_in_a_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." From 6572efde594959dde4ef4b79060b7d16a049005d Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 20:10:14 -0600 Subject: [PATCH 05/50] Exercise 5 --- section1/ex5.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 section1/ex5.rb diff --git a/section1/ex5.rb b/section1/ex5.rb new file mode 100644 index 00000000..a9d14e76 --- /dev/null +++ b/section1/ex5.rb @@ -0,0 +1,17 @@ +my_name = "Kaelin E. Sleevi" +my_age = 23 #not a lie in 2009 +my_height = 59 #inches +my_weight = 135 #lbs +my_eyes = 'Blue/Green/Yellow' +my_teeth = 'White' +my_hair = 'Red' + +puts "Let's talk about #{my_name}." +puts "She's #{my_height} inches tall." +puts "She's #{my_weight} pounds heavy." +puts "Actually that's not too heavy." +puts "She's got #{my_eyes} eyes and #{my_hair} hair." +puts "Her teeth are usually #{my_teeth} depending on the coffee." + +#this line is a little tricky, try to get it exactly right +puts "If I add #{my_age}, #{my_height}, and #{my_weight} I get #{my_age + my_height + my_weight}." From f70388b830064ac229bfa91d698a2aec10044e4b Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 20:21:39 -0600 Subject: [PATCH 06/50] Exercise 6 --- section1/ex6.rb | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 section1/ex6.rb diff --git a/section1/ex6.rb b/section1/ex6.rb new file mode 100644 index 00000000..811a74cb --- /dev/null +++ b/section1/ex6.rb @@ -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 From 6d22c6e4c17ac34f628267dbcefa24291cbc9171 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 20:25:32 -0600 Subject: [PATCH 07/50] Exercise 7 --- section1/ex7.rb | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 section1/ex7.rb diff --git a/section1/ex7.rb b/section1/ex7.rb new file mode 100644 index 00000000..4bd3b190 --- /dev/null +++ b/section1/ex7.rb @@ -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." From 91d8a2368a9332168099acfb6b448a3aa2893949 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Tue, 7 Jun 2022 22:33:56 -0600 Subject: [PATCH 08/50] section one work and answers --- section1/exercises/booleans.rb | 3 +++ section1/exercises/interpolation.rb | 16 ++++++++++------ section1/exercises/loops.rb | 12 +++++++----- section1/exercises/numbers.rb | 6 +++--- section1/exercises/strings.rb | 6 +++--- section1/exercises/variables.rb | 24 +++++++++++++----------- section1/reflection.md | 11 +++++++++++ 7 files changed, 50 insertions(+), 28 deletions(-) diff --git a/section1/exercises/booleans.rb b/section1/exercises/booleans.rb index 58e4dba9..67f37985 100644 --- a/section1/exercises/booleans.rb +++ b/section1/exercises/booleans.rb @@ -10,7 +10,10 @@ p 7 > 2 # YOU DO: print to the terminal the result of "hello" is equal to "Hello": +p "hello" == "Hello" # YOU DO: print to the terminal the result of 3 is not equal to 4: +p 3 < 4 # YOU DO: print to the terminal the result of 4 is less than or equal to 5: +p 4 <= 5 diff --git a/section1/exercises/interpolation.rb b/section1/exercises/interpolation.rb index 199ba2c0..ff2374e5 100644 --- a/section1/exercises/interpolation.rb +++ b/section1/exercises/interpolation.rb @@ -15,20 +15,24 @@ speedy = "quick red fox" slow_poke = "lazy brown dog" -p # YOUR CODE HERE - +# 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}!" # 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, print ONE sentence that incorporates +# 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, print ONE sentence that incorporates # all THREE variables. +my_job = "barista" +my_school = "Turing" +my_goal = "Software Engineer" # YOUR CODE HERE +p "I am currently a #{my_job} full time and I go to #{my_school} so that I can become a #{my_goal}!" diff --git a/section1/exercises/loops.rb b/section1/exercises/loops.rb index e8e69523..1d46c152 100644 --- a/section1/exercises/loops.rb +++ b/section1/exercises/loops.rb @@ -10,13 +10,15 @@ # 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 91435ffb..be4a3c5d 100644 --- a/section1/exercises/numbers.rb +++ b/section1/exercises/numbers.rb @@ -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 diff --git a/section1/exercises/strings.rb b/section1/exercises/strings.rb index a1cafe66..a7cd416c 100644 --- a/section1/exercises/strings.rb +++ b/section1/exercises/strings.rb @@ -7,10 +7,10 @@ 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..." # Write out code to print one line from your favorite song or movie. -# YOUR CODE HERE +p "I have everything I need, all of this is within me..." diff --git a/section1/exercises/variables.rb b/section1/exercises/variables.rb index 876f7390..18b208ff 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,31 +11,33 @@ # 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 +name = "Harry Potter" +location = "Hogwarts" +p "#{name} must not return to #{location}!" # Write code that adds 2 to the `students` variable and # prints the result: students = 22 -# YOUR CODE HERE -p students +new_students = 2 +p students + new_students # Write code that subracts 2 from the `students` variable and # prints the result: -# YOUR CODE HERE -p students +students = 22 +leaving_students = 2 +p students - leaving_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. # IN WORDS: -# How did you decide to use the data type you did for each of the three variables above? +# How did you decide to use the data type you did for each of the three variables above? # Explain. @@ -57,4 +59,4 @@ #------------------- # Did you run this file in your terminal to make sure everything printed out -# to the terminal as you would expect? +# to the terminal as you would expect? diff --git a/section1/reflection.md b/section1/reflection.md index dd6c2f2e..887f04ce 100644 --- a/section1/reflection.md +++ b/section1/reflection.md @@ -1,19 +1,30 @@ ## Section 1 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 tend to wait too long to ask questions. I try to do things on my own work before I reach out. 2. How would you print the string `"Hello World!"` to the terminal? +- Puts "Hello World!" into the file of your choice and then run in the terminal 'ruby ' 3. What character is used to indicate comments in a ruby file? +- '#' 4. Explain the difference between an integer and a float? +- The integer is a whole number and a float is a decimal for a more accurate number. 5. In the space below, create a variable `animal` that holds the string `"zebra"` +- animal = zebra 6. How would you print the string `"zebra"` using the variable that you created above? +- puts #{animal} 7. What is interpolation? Use interpolation to print a sentence using the variable `animal`. +- Creating a sentence as a whole output where the variable is included as a whole sentence. +- puts "There are this many #{animal} in the zoo!" 8. What method is used to get input from a user? +- "gets.chomp" 9. Name and describe two common string methods: +- putting double quotes (") around a piece of text. +- using a #{} sequence From 8578abc4580dc6a4236ce5a01c3779846da4271f Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 12:28:01 -0600 Subject: [PATCH 09/50] add vocabulary for section 2 --- section2/exercises/vocabulary.rb | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 section2/exercises/vocabulary.rb diff --git a/section2/exercises/vocabulary.rb b/section2/exercises/vocabulary.rb new file mode 100644 index 00000000..d53d7c0c --- /dev/null +++ b/section2/exercises/vocabulary.rb @@ -0,0 +1,6 @@ +if statements: +- An if-statement creates what is called a "branch" in the code. It's kind of like those choose your own adventure books where you are asked to turn to one page if you make one choice, and another if you go a different direction. It executes true-or-false expressions. + + +method: +- A method is a set of expressions that returns a value. From a2098eba4f0cafc3429dea7013472ec601737a05 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 12:28:54 -0600 Subject: [PATCH 10/50] add work on exercise 29: what if? --- section2/exercises/ex29.rb | 45 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 section2/exercises/ex29.rb diff --git a/section2/exercises/ex29.rb b/section2/exercises/ex29.rb new file mode 100644 index 00000000..cacdb1e1 --- /dev/null +++ b/section2/exercises/ex29.rb @@ -0,0 +1,45 @@ +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 equal to dogs." +end + + +if people == dogs + puts "People are dogs." +end + +1. Why does the code under the if need to be indented two spaces? + - The if creates a branch and that branch is the code under it. That way when we enter in the variable or change it, the code under is able to tell us if it is true or not. +2. What happens if it isn't indented? + - It is done so that you and other people know that is a block of code. +3. Can you put other boolean expressions from Exercise 27 in the if-statement? Try it. + - Yes +4. What happens if you change the initial values for people, cats, and dogs? + - Different statements will be true or false depending on the value change and the if statements. From 028a99625b6f848dd77935c9af6b50e863e48225 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 12:29:36 -0600 Subject: [PATCH 11/50] add work on exercise 30: else and if --- section2/exercises/ex30.rb | 57 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 section2/exercises/ex30.rb diff --git a/section2/exercises/ex30.rb b/section2/exercises/ex30.rb new file mode 100644 index 00000000..515f4770 --- /dev/null +++ b/section2/exercises/ex30.rb @@ -0,0 +1,57 @@ +people = 30 +cars = 40 +trucks = 15 + +#if there are more cars than people then it prints "We should take the cars." +#if there are more people than cars then it prints "We should not take the cars." +#if both people and car are equal it prints "We can't decide." +if cars > people + puts "We should take the cars." +elsif cars < people + puts "We should not take the cars." +else + puts "We can't decide." +end +#if there are more trucks than cars then it prints "That's too many trucks." +#if there are more cars than trucks then it prints "Maybe we could take the trucks." +#if both trucks and car are equal it prints "We still can't decide." +if trucks > cars + puts "That's too many trucks." +elsif trucks < cars + puts "Maybe we could take the trucks." +else + puts "We still can't decide." +end +#if there are more people then trucks then it prints "Alright, let's just take the trucks." +#if both people and trucks are equal it prints "Fine, let's stay home then." +if people > trucks + puts "Alright, let's just take the trucks." +else + puts "Fine, let's stay home then." +end + +1. Try to guess what elsif and else are doing. + - I would guess elsif is being used or is giving a second possibilty for another true or false statement. Else is a third option if neither the if or elsif statements are true. +2. Change the numbers of cars, people, and trucks, and then trace through each if-statement to see what will be printed. + - If people is changed to 50 the printed would be: + - "We should not take the cars." + - "Maybe we could take the trucks." + - "Alright, let's just take the trucks" + - If cars is changed to 10 the printed would be: + - "We should not take the cars." + - "That's too many trucks." + - "Alright, let's just take the trucks." + - If trucks changed to 30 the printed would be: + - "We should take the cars." + - "Maybe we could take the trucks." + - "Fine, let's stay home then." +3. Try some more complex boolean expressions like cars > people || trucks < cars. + - if cars > people || trucks < cars + puts "Let's just take the cars." + elsif cars < people || trucks > cars + puts "Alright, let's take the trucks" + else + puts "Let's stay home." + end + +4. Above each line write an English description of what the line does. From 8f9e9631f27dd6b5d4821ee7b243f2f7390b8a88 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 12:30:38 -0600 Subject: [PATCH 12/50] add work on exercise 31: making decisions --- section2/exercises/ex31.rb | 125 +++++++++++++++++++++++++++++++++++++ 1 file changed, 125 insertions(+) create mode 100644 section2/exercises/ex31.rb diff --git a/section2/exercises/ex31.rb b/section2/exercises/ex31.rb new file mode 100644 index 00000000..a49cd553 --- /dev/null +++ b/section2/exercises/ex31.rb @@ -0,0 +1,125 @@ +puts "You enter a dark room with two doors. Do you go through 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 revolvers yelling melodies." + + print "> " + insanity = $stdin.gets.chomp + +if insanity == "1" || insanity == "2" + puts "Your body survives powered by a mind of jello. Good job!" +else + puts "The insanity rots your eyes into a pool of muck. Good job!" +end + +else + puts "You stumble around and fall on a knife and die. Good job!" +end + +1. Make new parts of the game and change what decisions people can make. Expand the game out as much as you can before it gets ridiculous. +puts "You enter a dark room with two doors. Do you go through 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." + puts "3. Set the table for you and 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!" +elsif bear == "3" + puts "The bear offers you cake, but it's a trick and he eats you." +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 revolvers yelling melodies." + puts "4. You reincarnate H.P. Lovecraft." + + print "> " + insanity = $stdin.gets.chomp + +if insanity == "2" || insanity == "4" + puts "The insanity rots your eyes into a pool of muck. Good job!" +else + puts "H.P. Lovecraft appears and erases his creation from existence. Good job!" +end + +else + puts "You stumble around and fall on a knife and die. Good job!" +end + +2. Write a completely new game. Maybe you don't like this one, so make your own. This is your computer; do what you want. +puts "You are driving down the road at night and hit a fork. Do you drive down the left or right?" + +print "> " +road = $stdin.gets.chomp + +if road == "left" + puts "There's a bridge with sea monsters below. What do you do?" + puts "1. Drive across the bridge." + puts "2. Turn the car around." + + print "> " + road = $stdin.gets.chomp + +if road == "1" + puts "The bridge collaspes and you are eaten. Nice!" +elsif road == "2" + puts "The road has been blocked by fallen trees and you must go across the bridge. Nice!" +else + puts "Well, doing %s somehow helped you. Sea monsters swim away." % road +end + +elsif door == "2" + puts "You come to a dead end and find Bigfoots camp." + puts "1. Try to get evidence of Bigfoot." + puts "2. Scream for help nearby." + puts "3. Look through his camp to find supplies to get home." + + print "> " + survivial = $stdin.gets.chomp + +if survival == "1" || survival == "3" + puts "Bigfoot crushed your camera, took your supplies, and your car. You're stuck." +else + puts "Bigfoot thinks you are stealing his supplies and crushes you. Yay!" +end + +else + puts "Bigfoot feels bad for you and gives you a map home. Great!" +end From b0a3d1b74f19371ff2b24e9be57fdd6f6f72261c Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 12:32:55 -0600 Subject: [PATCH 13/50] update answers on reflections for section 2 --- section2/reflection.md | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/section2/reflection.md b/section2/reflection.md index 93bc6aa9..dd66940f 100644 --- a/section2/reflection.md +++ b/section2/reflection.md @@ -1,15 +1,42 @@ ## Section 2 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? +-I resonated with the seeking out challenges point. Many times in my life before the age of 18 I would avoid being challenged. I did not begin to understand taking on challenges until the age of 18. I reflected on how much I have changed in the past five years by being challenged and push. 2. In which ways do you currently demonstrate a Growth Mindset? In which ways do you _not_? +The ways I do demonstrate a growth mindset +- seeking out challenges. +- understanding my mistakes are a part of the learning process and to not be afraid to make mistakes while in the learning process. +The way I do _not_ +- practicing goals. I have always struggled with setting realistic and relevant goals. +- seeking help. Most of my life I have relied entirely on myself. I have issues admitting the need for help in many situations. 3. What is a conditional statement? Give three examples. +- Conditional statements evaluate to true or false. Three examples: + - if cats >= dogs + - if cats == dogs + - if cats < dogs 4. Why might you want to use an if-statement? - +- based on what you are working on you might want to test if the conditionals are true in your code for your project or company. 5. What is the Ruby syntax for an if statement? +- if conditional [then] +code... +[elsif conditional [then] +code...]... +[else +code...] +end 6. How do you add multiple conditions to an if statement? +- elsif, else -7. Provide an example of the Ruby syntax for an if/elsif/else statement: \ No newline at end of file +7. Provide an example of the Ruby syntax for an if/elsif/else statement: +- for example: +if predators > prey + puts "We won't survive against them." +elsif predators < prey + puts "We could survive against them for awhile." +else + puts "We will just hide." +end From e15aaa9b46f3c7c0e9aaa87a306fcaa0772f2440 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 14:06:18 -0600 Subject: [PATCH 14/50] add ruby in 100 minutes work --- section2/exercises/ex32.rb | 170 +++++++++++++++++++++++++++++++++++++ 1 file changed, 170 insertions(+) create mode 100644 section2/exercises/ex32.rb diff --git a/section2/exercises/ex32.rb b/section2/exercises/ex32.rb new file mode 100644 index 00000000..b4e7ebf7 --- /dev/null +++ b/section2/exercises/ex32.rb @@ -0,0 +1,170 @@ +Exercises + +Use IRB to store values with each of the following variable names. Which names are good, which are actually invalid Ruby, and which are valid but go against Ruby style? +1. time_machine: + - This is a good variable, it gives a descripton of the variable and uses snake_case. +2. student_count_integer: + - This could be a good variable, but the "integer" part is not necessary. The student count will be an integer either way. You can make it shorter without the excess word. +3. homeworkAssignment + - This is a bad variable and is invalid in ruby. It uses camel_case rather than snake_case. It should be homework_assignment +4. 3_sections + - This is a bad variable and is invalid in ruby. To name your variable it can not be named starting with an interger. It should be three_sections. +4. top_ppl + - This is a bad variable and is invalid in ruby. The word "ppl" is an abbreviation rather than using "people". It should be top_people. + +String methods + +.split and .length + irb(main):001:0> name = "Kaelin Elizabeth Sleevi" + => "Kaelin Elizabeth Sleevi" + irb(main):002:0> name.length + => 23 + irb(main):003:0> name.split + => ["Kaelin", "Elizabeth", "Sleevi"] + irb(main):004:0> numbers = "one,two,three,four,five" + => "one,two,three,four,five" + irb(main):005:0> numbers.split + => ["one,two,three,four,five"] + irb(main):006:0> numbers.split(",") + => ["one", "two", "three", "four", "five"] + irb(main):007:0> + +Combining strings and variables + +name = "Kaelin Elizabeth Sleevi" + puts "Good morning," + name + "!" + +- executing code inside interpolation +modifier = "very" +mood = "excited" +puts "I am #{modifier * 3 + mood} for today's class" + +Compare the methos list for proper string versus: +1. "hello".methods + - In the string method before, you would use the method attached to the variable, but not the variables assignment to a string. +2. "hello".methods.count + _ The mthod is again being attached to a string and not the variable that is assigned to the string. There are also two methods attached. +3. :hello.methods + - Uses a symbol as the vairable that is a broken down string. Yet aagin not assigning a method to the variable. +4. :hello.methods.count + - Uses a symbol as a variable and two methods again + +Repeating instructions +- 5. times do + puts "Hello,World!" + end + - Hello,World! + Hello,World! + Hello,World! + Hello,World! + Hello,World! +Above is also an example of a ruby block. It has a command, and output, and an end. Usually starting with do. + + +Arrays in code +--- --- --- +| || || | +--- --- --- + 0 1 2 + +------------- --------- ---------- +| "Breakfast" || "Lunch" || "Dinner" | +------------- --------- ---------- + 0 1 2 + +------------- --------- ---------- ----------- +| "Breakfast" || "Lunch" || "Dinner" || "Dessert" | +------------- --------- ---------- ----------- + 0 1 2 3 + +meals = ["Breakfast", "Lunch", "Dinner"] +["Breakfast", "Lunch", "Dinner"] +meals << "Dessert" +["Breakfast", "Lunch", "Dinner", "Dessert"] +meals[2] +"Dinner" +meals.last +"Dessert" + +- (<<) shovel operator +- ([]) fetch the element at a specific point using the square brackets +- ```.last``` is a method to get the last of the Array + +Common array methods to try +- each +- collect +- first and last +- shuffle + +irb(main):001:0> one = ["this", "is", "an", "array"] +=> ["this", "is", "an", "array"] +irb(main):002:0> one.sort +=> ["an", "array", "is", "this"] +irb(main):003:0> one.each +=> # +irb(main):004:0> one.first +=> "this" +irb(main):005:0> one.last +=> "array" +irb(main):006:0> one.shuffle +=> ["array", "this", "is", "an"] +irb(main):007:0> one.collect +=> # +irb(main):009:0> + +Hashes practice +irb(main):001:0> produce = {"grapes" => 221, "oranges" => 6, "carrots" => 12} +=> {"grapes"=>221, "oranges"=>6, "carrots"=>12} +irb(main):002:0> produce.keys +=> ["grapes", "oranges", "carrots"] +irb(main):003:0> produce.values +=> [221, 6, 12] +irb(main):004:0> produce +=> {"grapes"=>221, "oranges"=>6, "carrots"=>12} +irb(main):005:0> + +Conditionals practice +irb(main):002:1* def water_status(minutes) +irb(main):003:2* if minutes < 7 +irb(main):004:2* puts "The water is not boiling yet." +irb(main):005:2* elsif minutes == 7 +irb(main):006:2* puts "It's just barely boiling" +irb(main):007:2* elsif minutes == 8 +irb(main):008:2* puts "It's boiling!" +irb(main):009:2* else +irb(main):010:2* puts "Hot! Hot! Hot!" +irb(main):011:1* end +irb(main):012:0> end +=> :water_status +irb(main):013:0> water_status (5) +The water is not boiling yet. +=> nil +irb(main):014:0> water_status (7) +It's just barely boiling +=> nil +irb(main):016:0> water_status (8) +It's boiling! +=> nil +irb(main):017:0> water_status (9) +Hot! Hot! Hot! +=> nil +irb(main):018:0> + + +Objects, Attributes, and Methods prectice + +class Student + attr_accessor :first_name, :last_name, :primary_phone_number + + def introduction(target) + puts "Hi #{target}, I'm #{first_name}!" + end +end + +frank = Student.new +frank.first_name = "Frank" +frank.introduction('Kaelin + + /Users/kaelinsleevi/turing/0module/mod-0-project-be/section2/exercises main $ruby practice.rb + Hi Kaelin, I'm Frank! + /Users/kaelinsleevi/turing/0module/mod-0-project-be/section2/exercises main $ From 6c50fed640b4a332044917ae21b3a39bfdb326c8 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 15:07:09 -0600 Subject: [PATCH 15/50] add reflection answers section 2 --- section2/reflection.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/section2/reflection.md b/section2/reflection.md index dd66940f..6daa9c1a 100644 --- a/section2/reflection.md +++ b/section2/reflection.md @@ -21,15 +21,15 @@ The way I do _not_ - based on what you are working on you might want to test if the conditionals are true in your code for your project or company. 5. What is the Ruby syntax for an if statement? - if conditional [then] -code... -[elsif conditional [then] -code...]... -[else -code...] + code +elsif conditional [then] + code +else + code end 6. How do you add multiple conditions to an if statement? -- elsif, else +- elsif 7. Provide an example of the Ruby syntax for an if/elsif/else statement: - for example: From 056dcc499820ceed6c308d06f20d58dc1b7f25f9 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 15:14:11 -0600 Subject: [PATCH 16/50] add if statement answers section 2 --- section2/exercises/if_statements.rb | 38 +++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/section2/exercises/if_statements.rb b/section2/exercises/if_statements.rb index f29c45cd..14d17192 100644 --- a/section2/exercises/if_statements.rb +++ b/section2/exercises/if_statements.rb @@ -3,7 +3,7 @@ # 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" @@ -26,7 +26,19 @@ # Experiment with manipulating the value held in variable 'weather' # to print something other than 'coat' +weather = 'rainy' +if weather == 'sunny' + p "sunscreen" +elsif weather == 'rainy' + p "umbrella" +elsif weather == 'snowy' + p "coat" +elsif weather == 'icy' + p "yak traks" +else + p "good to go!" +end ################## # Using the num_quarters variable defined below, determine @@ -35,21 +47,25 @@ # 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 +gumball = 1 -puts "I have enough money for a gumball" -puts "I don't have enough money for a gumball" +if gumball < num_quarters + puts "I have enough money for a gumball" +elsif gumball > num_quarters + 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: @@ -63,3 +79,15 @@ cups_of_flour = 1 has_sauce = true + +if cups_of_flour < 2 + puts "I cannot make pizza" +elsif cups_of_flour >= 5 + puts "I cannot make pizza" +elsif cups_of_flour > 1 + puts "I can make pizza" +elsif has_sauce == true + puts "I can make pizza" +elsif has_sauce == false + puts "I cannot make pizza" +end From f8abed0d0bfacac1a2cbdc6271363cf493fe8ca9 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Sat, 11 Jun 2022 15:21:33 -0600 Subject: [PATCH 17/50] Update reflection.md --- section2/reflection.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/section2/reflection.md b/section2/reflection.md index 6daa9c1a..2c69a858 100644 --- a/section2/reflection.md +++ b/section2/reflection.md @@ -32,7 +32,7 @@ end - elsif 7. Provide an example of the Ruby syntax for an if/elsif/else statement: -- for example: +for example: if predators > prey puts "We won't survive against them." elsif predators < prey From 83fc367419b9217bf0f608db99e3bca453a779e2 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Sat, 11 Jun 2022 15:22:06 -0600 Subject: [PATCH 18/50] Update reflection.md --- section2/reflection.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/section2/reflection.md b/section2/reflection.md index 2c69a858..a1439a97 100644 --- a/section2/reflection.md +++ b/section2/reflection.md @@ -32,7 +32,8 @@ end - elsif 7. Provide an example of the Ruby syntax for an if/elsif/else statement: -for example: + +For example: if predators > prey puts "We won't survive against them." elsif predators < prey From e9a57d8a58551b83f1fc5610ef6a657d4e224725 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Sat, 11 Jun 2022 15:49:20 -0600 Subject: [PATCH 19/50] Update reflection.md --- section1/reflection.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/section1/reflection.md b/section1/reflection.md index 887f04ce..bf9b1e7a 100644 --- a/section1/reflection.md +++ b/section1/reflection.md @@ -1,30 +1,30 @@ ## Section 1 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 tend to wait too long to ask questions. I try to do things on my own work before I reach out. + - I tend to wait too long to ask questions. I try to do things on my own work before I reach out. 2. How would you print the string `"Hello World!"` to the terminal? -- Puts "Hello World!" into the file of your choice and then run in the terminal 'ruby ' + - Puts "Hello World!" into the file of your choice and then run in the terminal 'ruby ' 3. What character is used to indicate comments in a ruby file? -- '#' + - '#' 4. Explain the difference between an integer and a float? -- The integer is a whole number and a float is a decimal for a more accurate number. + - The integer is a whole number and a float is a decimal for a more accurate number. 5. In the space below, create a variable `animal` that holds the string `"zebra"` -- animal = zebra + - animal = zebra 6. How would you print the string `"zebra"` using the variable that you created above? -- puts #{animal} - + - puts #{animal} + 7. What is interpolation? Use interpolation to print a sentence using the variable `animal`. -- Creating a sentence as a whole output where the variable is included as a whole sentence. -- puts "There are this many #{animal} in the zoo!" + - Creating a sentence as a whole output where the variable is included as a whole sentence. + - puts "There are this many #{animal} in the zoo!" 8. What method is used to get input from a user? -- "gets.chomp" + - "gets.chomp" 9. Name and describe two common string methods: -- putting double quotes (") around a piece of text. -- using a #{} sequence + - putting double quotes (") around a piece of text. + - using a #{} sequence From f5f88f76cae161a90ff6cd0037367b4666a4b137 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Sat, 11 Jun 2022 15:50:08 -0600 Subject: [PATCH 20/50] Update reflection answers From 5b9915ec7c6dd48a8e0876ab0df6cbc8a3882948 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 20:56:56 -0600 Subject: [PATCH 21/50] update answers for section 1: a good first program --- section1/ex1.rb | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/section1/ex1.rb b/section1/ex1.rb index ebec88bd..9f39cf73 100644 --- a/section1/ex1.rb +++ b/section1/ex1.rb @@ -1,7 +1,17 @@ +Exercise puts "Hello World!" -puts "Hello Again" +#puts "Hello Again" puts "I like typing this." -puts "This is fun." +#puts "This is fun." puts "Yay! Printing." -puts "I'd much rather you 'not'." +#puts "I'd much rather you 'not'." puts 'I "said" do not touch this.' +#puts "This is another line." + +Study Drills +1. Make your script print another line. + - I added "puts 'This is another line.'" at the very end. +2. Make your script print only one of the lines. + - I used an octothorpe to in front of each line except one. +3. Put a # (octothorpe) character at the beginning of a line. What did it do? Try to find out what this character does. + - An octothorpe made ruby ignore the code following it. From d0749aef34c1d5772e27a5daac78a081c6df8ec8 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 20:57:32 -0600 Subject: [PATCH 22/50] update answers for section 2: comments in code --- section1/ex2.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/section1/ex2.rb b/section1/ex2.rb index dffb2b27..6e3a15fa 100644 --- a/section1/ex2.rb +++ b/section1/ex2.rb @@ -1,3 +1,4 @@ +Exercise # A comment, this is so you can read your program later. # Anything after the # is ignored by ruby. @@ -7,3 +8,13 @@ # puts "This won't run." puts "This will run." + +Study Drills +1. Find out if you were right about what the # character does and make sure you know what it's called (octothorpe or pound character) + - I was right about the octothorpe. The symbol is used to make note in the code without disturbing it. The symbol tells ruby to ignore it and everything after in that line. +2. Take your ex2.rb file and review each line going backward. Start at the last line, and check each word in reverse against what you should have typed. + +3. Did you find more mistakes? Fix them. + - No +4. Read what you typed above out loud, including saying each character by its name. Did you find more mistakes? Fix them. + - No From e92ccb3593011b75c518f316275f690e630550e0 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 20:58:11 -0600 Subject: [PATCH 23/50] update answers for section 3: numbers and math --- section1/ex3.rb | 42 +++++++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 17 deletions(-) diff --git a/section1/ex3.rb b/section1/ex3.rb index 0b7380c6..b704d743 100644 --- a/section1/ex3.rb +++ b/section1/ex3.rb @@ -1,23 +1,31 @@ +Exercise +#prints the statement so I know what the code/equation is doing puts "I will now count my chickens:" - +#the amount of hens and roosters(integer) are calculated by the equation below puts "Hens #{25 + 30 / 6}" -puts "Roosters #{100 - 25 * 3 % 4}" - +puts "Roosters #{100 - 25 * 3.0 % 4.0}" +#prints a statment to know what the code/equation is now calculating puts "Now I will count the eggs:" - -puts 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 - +#this equation calculates the amount of eggs into one integer/amount +puts 3.0 + 2.0 + 1.0 - 5.2 + 4.0 % 2.1 - 1.3 / 4.0 + 6.5 +#asking a true or false question based on the equations 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}" - +#calculates this question in the equation to tell us if it is true or false +puts 3.0 + 2.0 < 5.2 - 7.3 +#both line 16 and 17 are asking ruby to calculate the equations below. +puts "What is 3 + 2? #{3.0 + 2.0}" +puts "What is 5 - 7? #{5.2 - 7.3}" +#this line loops back to the question on line 12. After the equations are calculated it is telling you that your asnwer is why the equation is false puts "Oh, that's why it's false." - +#prints a statement letting us know we are going to do more calculations 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}" +#lines 23, 24, 25 are asking if eeach statement is true or false based on the calculations +puts "Is it greater? #{5.2 > -2.0}" +puts "Is it greater or equal? #{5.2 >= -2.0}" +puts "Is it less or equal? #{5.2 <= -2.0}" + +Study Drills +1. Above each line, use the # to write a comment to yourself explaining what the line does. +2. Remember in Exercise 0 when you started irb? Start irb this way again and, using the math operators, use Ruby as a calculator. +3. Find something you need to calculate and write a new .rb file that does it. +4. Rewrite ex3.rb to use floating point numbers so it's more accurate. 20.0 is floating point. From a2dc25d44d715e77cec312c5e2bae6d9a4104a5b Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 20:58:57 -0600 Subject: [PATCH 24/50] update answers for section 4: variables and names --- section1/ex4.rb | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/section1/ex4.rb b/section1/ex4.rb index 979127ae..908b6ba2 100644 --- a/section1/ex4.rb +++ b/section1/ex4.rb @@ -1,10 +1,19 @@ +Exercise +# the amount of cars in this scenario is 100 cars = 100 +# the amount of space within the car for passengers is 4.0 in a car space_in_a_car = 4.0 +# this means there are 30 drivers available drivers = 30 +# this refers to the amount of passengers there are which happens to be 90 passengers = 90 +# this refers to the amount of cars that are not driven. In this case it is the amount of cars minus dirvers which is 60 cars_not_driven = cars - drivers +# this variable represents how many cars will be driven based on the amount of drivers which is 30 cars_driven = drivers +# the carpool_capacity refers to how many people can carpool together which is the cars_driven multiplied by space_in_a_car carpool_capacity = cars_driven * space_in_a_car +# this refers to the average amount of people that will ride in each car which is passengers divided by cars_driven average_passengers_per_car = passengers / cars_driven @@ -14,3 +23,33 @@ puts "We can transport #{carpool_capacity} people today." puts "We have #{passengers} to carpool today." puts "We need to put about #{average_passengers_per_car} in each car." + +Study Drills + +```There are 100 cars available.``` +```There are only 30 drivers available.``` +```There will be 70 empty cars today.``` +```ex4.rb:14: undefined local variable or method "carpool_capacity" for + main:Object (NameError)``` + +1. Explain this error in your own words. Make sure you use line numbers and explain why. + - In my own words I would say that you neglected to give a defined variable or a variable that was a float or integer. + - Say I printed this out but I neglected to define "carpool_capacity". It would look like this: + cars = 100 +space_in_a_car = 4.0 +drivers = 30 +passengers = 90 +cars_not_driven = cars - drivers +cars_driven = drivers +carpool_capacity = +average_passengers_per_car = passengers / cars_driven + - The puts "We can transport #{carpool_capacity} people today" would not go through. + +2. I used 4.0 for space_in_a_car, but is that necessary? What happens if its just 4? + - 4.0 and 4 are technically the same number, but 4 is an integer and 4.0 is a float. If you just use 4 the output will just be an integer. + +3. Remember that 4.0 is a floating point number. It's just a number with a decimal point, and you need 4.0 instead of just 4 so that it is floating point. +3. Write comments above each of the variable assignments. +4. Make sure you know what = is called (equals) and that its purpose is to give data (numbers, strings, etc.) names (cars_driven, passengers). +5. Remember that _ is an underscore character. +6. Try running ruby from the Terminal as a calculator like you did before, and use variable names to do your calculations. Popular variable names are also i, x, and j. From c3a9666d11dfd653955040e3f33e99fd387f6b73 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 20:59:33 -0600 Subject: [PATCH 25/50] update answers for section 5: strings --- section1/ex5.rb | 40 ++++++++++++++++++++++++++++------------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/section1/ex5.rb b/section1/ex5.rb index a9d14e76..43879185 100644 --- a/section1/ex5.rb +++ b/section1/ex5.rb @@ -1,17 +1,33 @@ -my_name = "Kaelin E. Sleevi" -my_age = 23 #not a lie in 2009 -my_height = 59 #inches -my_weight = 135 #lbs -my_eyes = 'Blue/Green/Yellow' -my_teeth = 'White' -my_hair = 'Red' +Exercise +myname = "Kaelin E. Sleevi" +myage = 23 #not a lie in 2009 +myheight = 175.26 #centimeters +myweight = 61.29 #kilograms +myeyes = 'Blue/Green/Yellow' +myteeth = 'White' +myhair = 'Red' -puts "Let's talk about #{my_name}." -puts "She's #{my_height} inches tall." -puts "She's #{my_weight} pounds heavy." +puts "Let's talk about #{myname}." +puts "She's #{myheight} inches tall." +puts "She's #{myweight} pounds heavy." puts "Actually that's not too heavy." -puts "She's got #{my_eyes} eyes and #{my_hair} hair." -puts "Her teeth are usually #{my_teeth} depending on the coffee." +puts "She's got #{myeyes} eyes and #{myhair} hair." +puts "Her teeth are usually #{myteeth} depending on the coffee." #this line is a little tricky, try to get it exactly right puts "If I add #{my_age}, #{my_height}, and #{my_weight} I get #{my_age + my_height + my_weight}." + +Study Drills +1. Change all the variables so there is no my_ in front of each one. Make sure you change the name everywhere, not just where you used = to set them. + +2. Try to write some variables that convert the inches and pounds to centimeters and kilograms. Do not just type in the measurements. Work out the math in Ruby. +irb(main):004:0> 12 * 5 +=> 60 +irb(main):005:0> 2.54 * 69 +=> 175.26 +irb(main):006:0> + + +irb(main):006:0> 135 * 0.454 +=> 61.29 +irb(main):007:0> From 0c18f006a41b4f2b07f9b5deb53b0d62606dfcf1 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 21:00:14 -0600 Subject: [PATCH 26/50] update answers for section 6: more strings --- section1/ex6.rb | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/section1/ex6.rb b/section1/ex6.rb index 811a74cb..1538d4e7 100644 --- a/section1/ex6.rb +++ b/section1/ex6.rb @@ -1,21 +1,41 @@ +Exercise +# this assigns the variable "types_of_people" to the number. That way you have 10 types of people for the equation types_of_people = 10 +# this is assigning the variable "x" to a sting that includes the variable types_of_people to print as a statement x = "There are #{types_of_people} types of people." +# this line assigns the variable binary to "binary" binary = "binary" +# this variable do_not is being assigned to the string "don't" do_not = "don't" +# this assigns the variable "y" to a string that includes the variables binary and do_not in the printed statement y = "Those who know #{binary} and those who #{do_not}." - +# the shown variables here in line 13 and 14 are telling you that by putting "puts x/y" it will print the strings assigned to x/y as a statement. puts x puts y - +# the shown strings in line 16 and 17 tell ruby to print x/y within the strings shown below. Now the terminal will print "I said..."/"I also said..." with the strings x/y within that string. puts "I said: #{x}." puts "I also said: '#{y}'." - +# this assigns the vaiable of hilarious to false hilarious = false +# this is a assignment of the joke_evaluation to the string below that also inclues the variable/string assigned above joke_evaluation = "Isn't that joke so funny?! #{hilarious}" - +# this action will print the string assigned to joke_evaluation in the terminal along with the assigned variable of hilarious to be "false" puts joke_evaluation - +# these next two lines show the assignment of the variables w/e to the strings below w = "This is the left side of..." e = "a string with a right side." +# this action will print the strings assigned to w and e together. We know that because the two are being added together below. The addition of the two will print in the Terminal +puts w + e + +Study Drills +1. Go through this program and write a comment above each line explaining it. -puts w + e +2. Find all the places where a string is put inside a string. + - Lines 5, 16, 17, and 21 +3. Are you sure there are only four places? How do you know? Maybe I like lying. + - Yes, the rest of the lines are just assigned to one string (there is not another defined variable within the other assignments) or are the action of puts and the variable assigned. +4. Explain why adding the two strings w and e with + makes a longer string. + - It is adding two defined variables that are defined with strings together into one output. +5. What happens when you change the strings to use ' (single-quote) instead of " (double-quote)? Do they still work? Try to guess why. + - It depends, in some cases here it will make no difference, but in the strings that include an apostrophe the single quotations will open and close the strings in the wrong places. It will not print the same. + From c1d67a4a1bde730758c5683a23517117c597b388 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 11 Jun 2022 21:00:48 -0600 Subject: [PATCH 27/50] update answers for section 7: asking for input --- section1/ex7.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/section1/ex7.rb b/section1/ex7.rb index 4bd3b190..a8d431d8 100644 --- a/section1/ex7.rb +++ b/section1/ex7.rb @@ -1,3 +1,4 @@ +Exercise print "How old are you? " age = gets.chomp print "How tall are you? " @@ -6,3 +7,21 @@ weight = gets.chomp puts "So, you're #{age} old, #{height} tall and #{weight} heavy." + +Study Drills +1. Go online and find out what Rubys gets.chomp does. + - I found that the "gets" creates a new line and asks the user to input a integer, variable, float, etc. and gets.chomp does the same thing except that it does not create a new line. gets.chomp allows a user to input as well as "gets", but there will not be a new line that is added after the string. + +2. Can you find other ways to use it? Try some of the samples you find. +You can use it ask questions to the user, play a game or run through the game play, you can use it to have users put their own information into the code. + +3. Write another "form" like this to ask some other questions. + +print "What is your favorite food?" +food = gets.chomp +print "What dessert do you like?" +dessert = gets.chomp +print "What would you like to drink?" +drink = gets.chomp + +puts "So, you like #{food}, you would like #{dessert} and want #{drink} for a drink." From 6d5c5dbc3e598c1401b7bab322fa1f3357046149 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sun, 12 Jun 2022 16:25:22 -0600 Subject: [PATCH 28/50] add work from exercise 32: loops and arrays --- section3/ex32_loops_arrays.rb | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 section3/ex32_loops_arrays.rb diff --git a/section3/ex32_loops_arrays.rb b/section3/ex32_loops_arrays.rb new file mode 100644 index 00000000..4d989318 --- /dev/null +++ b/section3/ex32_loops_arrays.rb @@ -0,0 +1,32 @@ +Exercise +the_count = [1, 2, 3, 4, 5] +fruits = ['apples', 'oranges', 'pears', 'apricots'] +change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] + +the_count.each do |number| + puts "This is count #{number}" +end + +fruits.each do |fruit| + puts "A fruit type: #{fruit}" +end + +change.each {|i| puts "I got #{i}"} + +elements = [] + +(0..5).each do |i| + puts "adding #{i} to the list." + elements.push(i) +end + +elements.each {|i| puts "Element was: #{i}"} + +Study Drills +1. Take a look at how you used (0..5) in the last for-loop. Look up Ruby's "range operator" (.. and ...) online to see what it does. + - A "range operator" is: A range represents an interval, a set of values with a beginning and an end. Values of a range can be numbers, characters, strings or objects. + - You can use the elipses in ruby that supports ranges in a variety of ways including ranges as: sequences, conditions, and intervals. +2. Change the first for number in the_count to be a more typical .each style loop like the others. + - I changes the line to "the_count.each do |number|" +3. Find the Ruby documentation on arrays and read about them. What other operations can you do besides the push function? Try <<, which is the same as push but is an operator. fruits << x is the same as fruits.push(x). + - You can use "<<" function in lieu of "push". There are also other operations that can be used to print certain parts of your list like: ".first", ".last", [2], ".sort", ".each", ".collect", and ".shuffle". From f2b4e0cb0f520ea32e01fd43106c63f9501a00d1 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sun, 12 Jun 2022 16:25:58 -0600 Subject: [PATCH 29/50] add work from exercise 34: accessing elements --- section3/ex34_accessing_elements.rb | 40 +++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 section3/ex34_accessing_elements.rb diff --git a/section3/ex34_accessing_elements.rb b/section3/ex34_accessing_elements.rb new file mode 100644 index 00000000..07ee91df --- /dev/null +++ b/section3/ex34_accessing_elements.rb @@ -0,0 +1,40 @@ +Exercises +animals = ['bear', 'ruby', 'peacock', 'kangaroo', 'whale', 'platypus'] + +puts "The second (2nd) animal is at 1 and is a #{animals[1]}" +puts "The animal at 1 is the 2nd animal and is a #{animals[1]}" + +puts "The third (3rd) animal is at 2 and is a #{animals[2]}" +puts "The animal at 2 is the 3rd animal and is a #{animals[2]}" + +puts "The first (1st) animal is at 0 and is a #{animals[0]}" +puts "The animal at 0 is the 1st animal and is a #{animals[0]}" + +puts "The fourth (4th) animal is at 3 and is a #{animals[3]}" +puts "The animal at 3 is the 4th animal and is a #{animals[3]}" + +puts "The fifth (5th) animal is at 4 and is a #{animals[4]}" +puts "The animal at 4 is the 5th animal and is a #{animals[4]}" + +puts "The sixth (6th) animal is at 5 and is a #{animals[5]}" +puts "The animal at 5 is the 6th animal and is a #{animals[5]}" + +Study Dirlls +1. With what you know of the difference between these types of numbers, can you explain why the year 2010 in "January 1, 2010," really is 2010 and not 2009? (Hint: you cannot pick years at random.) + - The year 2010 really is 2010 and not 2009 because the start of the century begins at a 2000 just like the arrays starting at 0 the century started at 0 as well. +2. Write some more arrays and work out similar indexes until you can translate them. + - meals = ['breakfast', 'lunch', 'dinner', 'desert'] + + - puts "The first (1st) meal of the day is at 0 and is #{meals[0]}" + - puts "The meal at 0 is the 1st meal and is #{meals[0]}" + + - puts "The second (2nd) meal of the day is at 1 and is #{meals[1]}" + - puts "The meal at 1 is the 2nd meal and is #{meals[1]}" + + - puts "The third (3rd) meal of the day is at 2 and is #{meals[2]}" + - puts "The meal at 2 is the 3rd meal and is #{meals[2]}" + + - puts "The fourth (4th) meal of the day is at 3 and is #{meals[3]}" + - puts "The meal at 3 is the 4th meal and is #{meals[3]}" + +3. Use Ruby to check your answers. From e26892f30aad160142e39727ca917fb2536a7a9f Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sun, 12 Jun 2022 16:26:30 -0600 Subject: [PATCH 30/50] add work from exercise 39: hashes --- section3/ex39_hashes.rb | 169 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 169 insertions(+) create mode 100644 section3/ex39_hashes.rb diff --git a/section3/ex39_hashes.rb b/section3/ex39_hashes.rb new file mode 100644 index 00000000..72e1821a --- /dev/null +++ b/section3/ex39_hashes.rb @@ -0,0 +1,169 @@ +stuff = {'name' => 'Zed', 'age' => 39, 'height' => 6 * 12 + 2} + +puts stuff['name'] +puts stuff['age'] +puts stuff['height'] + +stuff['city'] = "San Francisco" +print stuff['city'] + +stuff[1] = "Wow" +stuff[2] = "Neato" + +puts stuff[1] +puts stuff[2] + +puts stuff + +# state to abbreviation +states = { + 'Oregon' => 'OR', + 'Florida' => 'FL', + 'California' => 'CA', + 'New York' => 'NY', + 'Michigan' => 'MI' +} + +# states and cities +cities = { + 'CA' => 'San Francisco', + 'MI' => 'Detroit', + 'FL' => 'Jacksonville' +} + +# abbreviated state map to their cities +cities['NY'] = 'New York' +cities['OR'] = 'Portland' + +# how many cities each state has(not really just an example) +# the "puts '-' * 10" prints 10 dashes to seperate each section of my work +puts '-' * 10 +puts "NY State has: #{cities['NY']}" +puts "OR State has: #{cities['OR']}" + +# showing you the assigned variable string to Florida and Michigan +puts '-' * 10 +puts "Michigan's abbreviation is: #{states['Michigan']}" +puts "Florida's abbreviation is: #{states['Florida']}" + +# we are now showing you the assigned vairables assigned to each variable cities within and the state itself +puts '-' * 10 +puts "Michigan has: #{cities[states['Michigan']]}" +puts "Florida has: #{cities[states['Florida']]}" +# this is how you would print each state with the name followed by their abbreviation +puts '-' * 10 +states.each do |state, abbrev| + puts "#{state} is abbreviated #{abbrev}" +end + +# here we are printing each city and the abbreviated state they are assigned to +puts '-' * 10 +cities.each do |abbrev, city| + puts "#{abbrev} has the city #{city}" +end + +# here we are printing each state, the assigned abbreviation and the cities that have been assigned to the state +puts '-' * 10 +states.each do |state, abbrev| + city = cities[abbrev] + puts "#{state} is abbreviated #{abbrev} and has city #{city}" +end + +puts '-' * 10 +# ruby says nil when something isn't in the list +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}" + +Study Drills + +1. Do this same kind of mapping with cities and states/regions in your country or some other country. + -states = { + 'Colorado' => 'CO', + 'Illinois' => 'IL', + 'Washington' => 'WA', + 'North Carolina' => 'NC', + 'South Carolina' => 'SC' + } + + cities = { + 'WA' => 'Seattle', + 'NC' => 'Jacksonville', + 'SC' => 'Charleston' + } + + cities['CO'] = 'Denver' + cities['IL'] = 'Chicago' + + puts '-' * 10 + puts "CO state has: #{cities['CO']}" + puts "IL state has: #{cities['IL']}" + + puts '-' * 10 + puts "Washington's abbreviation is: #{states['Washington']}" + puts "North Carolina's abbreviation is: #{states['North Carolina']}" + + puts '-' * 10 + puts "South Carolina has: #{cities[states['South Carolina']]}" + puts "North Carolina has: #{cities[states['North Carolina']]}" + + puts '-' * 10 + states.each do |state, abbrev| + city = cities[abbrev] + puts "#{state} is abbreviated #{abbrev} and has city #{city}" + end + +2. Find the Ruby documentation for hashes and try to do even more things to them. + - kay = { + 'First name' => 'Kaelin', + 'Last name' => 'Sleevi', + 'Age' => 23, + 'Nationality' => 'Irish', + 'Nickname' => 'Kay' + } + + kay.each do |key, value| + puts kay[key] + end + + grades = { + 'Jane Doe' => 10, + 'Jim Doe' => 6 + } + + options = { + font_size: 1, + font_family: 'Arial' + } + + grades.each do |key, value| + puts grades[key] + end + + options.each do |key, value| + puts options[key] + end + + grades = Hash.new + grades['Dororthy Doe'] = 9 + + grades = Hash.new(0) + + grades = {'Timmy Doe'=> 10} + grades.default = 0 + + puts grades['Jane Doe'] + puts grades['Jim Doe'] + puts grades['Dorothy Doe'] + puts grades['Timmy Doe'] + +3. Find out what you can't do with hashes. A big one is that they do not have order, so try playing with that. + - Apparently, as of Ruby version 1.9 hashes maintain an order in which they are stored. But it can not tore data in a specific order. + - We also cannot rely on just an index number to look or call the hashes out, so we use keys. From 3505db1064daf90a6fbc4466123273915b611b9a Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sun, 12 Jun 2022 16:27:12 -0600 Subject: [PATCH 31/50] ruby in 100 minutes: hashes --- section3/ex40_in_a_hundreds_minutes.rb | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 section3/ex40_in_a_hundreds_minutes.rb diff --git a/section3/ex40_in_a_hundreds_minutes.rb b/section3/ex40_in_a_hundreds_minutes.rb new file mode 100644 index 00000000..3a04567b --- /dev/null +++ b/section3/ex40_in_a_hundreds_minutes.rb @@ -0,0 +1,12 @@ +Exercise + +Hashes practice +irb(main):001:0> produce = {"grapes" => 221, "oranges" => 6, "carrots" => 12} +=> {"grapes"=>221, "oranges"=>6, "carrots"=>12} +irb(main):002:0> produce.keys +=> ["grapes", "oranges", "carrots"] +irb(main):003:0> produce.values +=> [221, 6, 12] +irb(main):004:0> produce +=> {"grapes"=>221, "oranges"=>6, "carrots"=>12} +irb(main):005:0> From 7464dbd6969d4d26cede0ccb7ed2f25d9235bcd1 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sun, 12 Jun 2022 17:29:03 -0600 Subject: [PATCH 32/50] add arrays practice answers --- section3/exercises/arrays.rb | 51 ++++++++++++++++++++---------------- 1 file changed, 29 insertions(+), 22 deletions(-) diff --git a/section3/exercises/arrays.rb b/section3/exercises/arrays.rb index 7c3b0ffc..ad35204a 100644 --- a/section3/exercises/arrays.rb +++ b/section3/exercises/arrays.rb @@ -5,7 +5,7 @@ # Two examples are already completed. Your task is to complete # any remaining prompt. -# To check your work, run this file by entering the following +# To check your work, run this file by entering the following # command in your terminal: # `ruby section3/exercises/arrays.rb`` @@ -16,7 +16,7 @@ # 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 @@ -25,43 +25,51 @@ # YOU DO: Write code below that will print the number of elements in array of # animals from above. - - +elements = [animals.count] +print elements # YOU DO: Write code that will reassign the last item in the animals # array to "Gorilla" - - +animals[2] = 'Gorilla' +print animals # YOU DO: Write code that will add a new animal (type of your choice) to position 3. - - +animals[3] = 'Shark' # YOU DO: Write code that will print the String "Elephant" in the animals array - +animals[2] = 'Elephant' +print animals #------------------- # PART 2: Foods: Array Methods #------------------- # YOU DO: Declare a variable that will store an an array of at least 4 foods (strings) - - +food = ['pasta', 'burger', 'curry', 'salad'] +print food # YOU DO: Write code below that will print the number of elements in the array of # foods from above. - +elements = [food.count] +print elements # 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' +print 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.delete_at(4) +print 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 << 'chicken' +food << 'steak' +food << 'mozzerela sticks' +print food # YOU DO: Remove the food that is in index position 0. - +food.delete_at(0) +print food #------------------- # PART 3: Where are Arrays used? #------------------- @@ -79,11 +87,10 @@ 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: - - +# I will be using the application Twitch +# 1: recent_broadcats = ['Elden Ring stream', ' Suprise DnD stream ', 'Friday night spookies!'] +# 2: recetly_streamed_categories = ['Just Chatting', 'Elden Ring', 'Poppy Playtime'] +# 3: suggested_streamers = ['CriticalRole', 'TheColeBrew', 'NotSaige'] From fc610b931268c13dbdcd616a19f59b4361e15f2b Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sun, 12 Jun 2022 19:16:51 -0600 Subject: [PATCH 33/50] add work and answers to exercise: hashes2 --- section3/exercises/hashes.rb | 82 ++++++++++++++++++++++++++---------- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/section3/exercises/hashes.rb b/section3/exercises/hashes.rb index 94825d27..4a4aa5ab 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,25 +8,39 @@ p foods # Write code that prints a hash holding zoo animal inventory: -zoo = #YOUR CODE HERE +puts '-' * 10 +zoo = { + penguins: 21, + lions: 4, + zebras: 7, + monkeys: 12 +} 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 +puts zoo.keys -# 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 +puts zoo.values -# 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 +puts '-' * 10 +puts zoo[:penguins] -# Write code that adds an animal to the zoo hash. +# Write code that adds an animal to the zoo hash. # Then, print the updated hash: -# YOUR CODE HERE +puts '-' * 10 +another_zoo = { + tigers: 30 +} +zoo.merge!(another_zoo) +puts zoo #------------------- # Part 2: Email @@ -40,15 +54,24 @@ # value should be some appropriate value for that key. Work to have at least 5 key-value pairs. # Write code that prints your email hash to the terminal. - - -# Write code that prints all of the 'keys' of the email hash +puts '-' * 10 +email = { + 'sender' => 'John Doe', + 'subject' => 'Important Homework Update', + 'body' => 'Session 3 homework has been changed...', + 'signature' => 'John Doe, Turing Inc., Contact Information' +} +puts email + +# Write code that prints all of the 'keys' of the email hash # you created above: -# YOUR CODE HERE +puts '-' * 10 +puts email.keys -# Write code that prints all of the 'values' of the email hash +# Write code that prints all of the 'values' of the email hash # you created above: -# YOUR CODE HERE +puts '-' * 10 +puts email.values #------------------- @@ -60,7 +83,7 @@ # Check out the following example of an array of Instagram posts: - +puts '-' * 10 posts = ["image at beach", "holiday party", "adorable puppy", "video of cute baby"] @@ -68,7 +91,7 @@ # for storing more complex data. Below, we can store multiple key-value pairs # that relate to each individual Instagram post: - +puts '-' * 10 posts = [ { image_src: "./images/beach.png", @@ -76,7 +99,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 +113,27 @@ p posts[0] -# The code snippet above shows an Array with 2 elements. Each element in the Array is a -# Hash. Each of those Hashes has 4 key-value pairs. This may LOOK +# The code snippet above shows an Array with 2 elements. Each element in the Array is a +# Hash. Each of those Hashes 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 Hashes, using the same +# YOU DO: Create an array of at least 3 EMAIL Hashes, using the same # key-value pairs you used in your email Hash above. # Then, print the email Array to the terminal. +puts '-' * 10 +email = { + 'sender' => 'John Doe', + 'subject' => 'Important Homework Update', + 'body' => 'Session 3 homework has been changed...', + 'signature' => 'John Doe, Turing Inc., Contact Information' +}, +{ + 'sender' => 'Jane Doe', + 'subject' => 'Comments On Project', + 'body' => 'I just wanted to point out some things I noticed...', + 'signature' => 'Jane Doe, Turing Inc., Contact Information' +} + +puts email From 3814bfb3fa61286880d4ab0777c58ab6bca5f6e4 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sun, 12 Jun 2022 19:18:00 -0600 Subject: [PATCH 34/50] update relection answers --- section3/reflection.md | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/section3/reflection.md b/section3/reflection.md index 673899ed..7d146eee 100644 --- a/section3/reflection.md +++ b/section3/reflection.md @@ -1,17 +1,29 @@ ## Section 3 Reflection 1. How different did your workflow feel this week, considering we asked you to follow the Pomodoro technique? + - It felt a lot better. Giving myself work blocks with increments of breaks built into the workflow gave me a lot more energy to finish this section. 2. 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 was surprised that I was a lot more focused on each piece I had set aside by step. I was off on estimating time for the second half of Part B at the end. It took me longer than the two hour increment I had set aside for it. 3. What is a Hash, and how is it different from an Array? + - A hash is a data structure that stores items by associated keys. This is different from arrays because it stores items by an order index. 4. 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. +- pet_store = { + dog_food_bags: 42 + cat_toys: 13 + fish: 65 + dog_leashes: 29 + } 5. Given the following `states = {"CO" => "Colorado", "IA" => "Iowa", "OK" => "Oklahoma"}`, how would you access the value `"Iowa"`? + - puts states['IA'] 6. With the same hash above, how would we get all the keys? How about all the values? + - states.each_key { |key| puts key} + - states.each_value { |value| put value} 7. What is another example of when we might use a hash? In your example, why is a hash better than an array? - -8. What questions do you still have about hashes? \ No newline at end of file + - We could use a hash to record definitions throughout the course. It is better than Array because I can literally map a definition to a word. It will be easier to find since it is stored by associated keys instead of having to sift through an ordered index. +8. What questions do you still have about hashes? From 3dc9b02f466c5250360795ce945497f70e7472d3 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Tue, 14 Jun 2022 15:55:00 -0600 Subject: [PATCH 35/50] Update README.md --- section4/README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/section4/README.md b/section4/README.md index e36f2e4f..4e261df5 100644 --- a/section4/README.md +++ b/section4/README.md @@ -22,9 +22,9 @@ Some things to consider as you refactor include... Take your time as you go back and refactor your exercises from each section. We've included a handy checklist for you to go through below. -- [ ] I have refactored my `section1` exercises to the best of my ability -- [ ] I have refactored my `section2` exercises to the best of my ability -- [ ] I have refactored my `section3` exercises to the best of my ability +- [X] I have refactored my `section1` exercises to the best of my ability +- [X] I have refactored my `section2` exercises to the best of my ability +- [X] I have refactored my `section3` exercises to the best of my ability ## Time Management Prep From 4a98841df2c46c00148364cc664022e01ea6c4f1 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Tue, 14 Jun 2022 16:27:10 -0600 Subject: [PATCH 36/50] Update README.md --- section4/README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/section4/README.md b/section4/README.md index 4e261df5..166fc53a 100644 --- a/section4/README.md +++ b/section4/README.md @@ -30,17 +30,20 @@ Take your time as you go back and refactor your exercises from each section. We' In Mod 0 you've learned about different techniques for managing your time at Turing. Please create a calendar for your **first 3 weeks of Mod 1**. Feel free to make your calendar fit your style, but we suggest that your calendar should include the following: -- [ ] Standard Mod 1 class schedule (find the Mod 1 calendar [on the Back End curriculum site](https://backend.turing.edu/)). The detailed classes held on your actual start date may not yet be posted; you can look back at the previous inning to get a feel for what Weeks 1-3 will be like, but know it's not guaranteed to be exactly the same. Also, as you already know, class is held from 9-12 and 1-4MT, Monday-Friday. -- [ ] Study/Project work time (usually about 25 hours/week outside of class time) -- [ ] Personal, Health + Wellness +- [X] Standard Mod 1 class schedule (find the Mod 1 calendar [on the Back End curriculum site](https://backend.turing.edu/)). The detailed classes held on your actual start date may not yet be posted; you can look back at the previous inning to get a feel for what Weeks 1-3 will be like, but know it's not guaranteed to be exactly the same. Also, as you already know, class is held from 9-12 and 1-4MT, Monday-Friday. +- [X] Study/Project work time (usually about 25 hours/week outside of class time) +- [X] Personal, Health + Wellness >Before you make your calendar - stop and think about how you are going to feel on Firday at 6pm. Are you really going to work all Friday evening? -> _Be realistic!_ 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` +- Screen Shot 2022-06-14 at 4 22 16 PM + +- Screen Shot 2022-06-14 at 4 22 30 PM + +- Screen Shot 2022-06-14 at 4 22 48 PM + ## Letter to Instructors From 3a15bd037fc8d63d3435b075ccbeebbcdd8006bc Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Tue, 14 Jun 2022 17:20:06 -0600 Subject: [PATCH 37/50] Update README.md --- section4/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/section4/README.md b/section4/README.md index 166fc53a..3a5b58d1 100644 --- a/section4/README.md +++ b/section4/README.md @@ -58,7 +58,8 @@ Create a new Gist. In it, write a letter introducing yourself to your future ins Make sure to include your full name and pronouns. -Provide link to your Gist here: +Provide link to your Gist here: [ +](https://gist.github.com/KaelinSleevi/6712ea9bea7598fce680dd07b6d77a2a) ## Mentorship Prep From e7908bb359a52a49c00ee1d44fcffb736c074348 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Tue, 14 Jun 2022 17:21:10 -0600 Subject: [PATCH 38/50] Update README.md --- section4/README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/section4/README.md b/section4/README.md index 3a5b58d1..64dbca76 100644 --- a/section4/README.md +++ b/section4/README.md @@ -58,8 +58,7 @@ Create a new Gist. In it, write a letter introducing yourself to your future ins Make sure to include your full name and pronouns. -Provide link to your Gist here: [ -](https://gist.github.com/KaelinSleevi/6712ea9bea7598fce680dd07b6d77a2a) +Provide link to your Gist here: https://gist.github.com/KaelinSleevi/6712ea9bea7598fce680dd07b6d77a2a ## Mentorship Prep From 031fa1edaa397977871e4fd89126fa248de41606 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Tue, 14 Jun 2022 19:21:12 -0600 Subject: [PATCH 39/50] Update README.md --- section4/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/section4/README.md b/section4/README.md index 64dbca76..e292b56b 100644 --- a/section4/README.md +++ b/section4/README.md @@ -65,8 +65,8 @@ Provide link to your Gist here: https://gist.github.com/KaelinSleevi/6712ea9bea7 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: - [ ] [Create a profile on Turing Community Connect by following these directions](https://docs.google.com/document/d/1vpyKGu92l1HGkJzULNcyyE72946f4QO1DhQgIz3v1E0/edit?usp=sharing) -- [ ] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) - - [ ] Add link to your gist here: +- [X] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) + - [X] Add link to your gist here: https://gist.github.com/KaelinSleevi/0a880d11c651b64bc93254df2348827d ## Group Work Prep From 569e2bcda9a2046749cd12cde80dc5751c1a3d05 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Tue, 14 Jun 2022 19:28:46 -0600 Subject: [PATCH 40/50] Update README.md --- section4/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/section4/README.md b/section4/README.md index e292b56b..477c61f0 100644 --- a/section4/README.md +++ b/section4/README.md @@ -64,7 +64,7 @@ Provide link to your Gist here: https://gist.github.com/KaelinSleevi/6712ea9bea7 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: -- [ ] [Create a profile on Turing Community Connect by following these directions](https://docs.google.com/document/d/1vpyKGu92l1HGkJzULNcyyE72946f4QO1DhQgIz3v1E0/edit?usp=sharing) +- [X] [Create a profile on Turing Community Connect by following these directions](https://docs.google.com/document/d/1vpyKGu92l1HGkJzULNcyyE72946f4QO1DhQgIz3v1E0/edit?usp=sharing) - [X] Complete the [Mentorship DTR Prep](https://gist.github.com/ericweissman/51965bdcbf42970d43d817818bfaef3c) - [X] Add link to your gist here: https://gist.github.com/KaelinSleevi/0a880d11c651b64bc93254df2348827d From 3d54f03b358373c3f4e65c04dfdc31c6e8f7c50b Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi <105956031+KaelinSleevi@users.noreply.github.com> Date: Tue, 14 Jun 2022 22:04:30 -0600 Subject: [PATCH 41/50] Update README.md --- section4/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/section4/README.md b/section4/README.md index 477c61f0..bfe9c8b1 100644 --- a/section4/README.md +++ b/section4/README.md @@ -72,8 +72,8 @@ Mentorship is an integral part of the Turing experience and will help jumpstart 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: +- [X] Complete the [DTR Guiding Questions](https://gist.github.com/ericweissman/c56f3a98cdce761808c21d498a52f5c6) + - [X] Add a link to your gist here: https://gist.github.com/KaelinSleevi/244db473bf3dbc27cfbc5298a4394555 ## Mod 0 Project Submission From fbca80c549f8d02e39d2a27aa9af5c96a39c6e94 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 16:39:09 -0600 Subject: [PATCH 42/50] update exercise 1 format --- section1/ex1.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/section1/ex1.rb b/section1/ex1.rb index 9f39cf73..234ccff2 100644 --- a/section1/ex1.rb +++ b/section1/ex1.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise puts "Hello World!" #puts "Hello Again" puts "I like typing this." @@ -8,10 +8,10 @@ puts 'I "said" do not touch this.' #puts "This is another line." -Study Drills -1. Make your script print another line. - - I added "puts 'This is another line.'" at the very end. -2. Make your script print only one of the lines. - - I used an octothorpe to in front of each line except one. -3. Put a # (octothorpe) character at the beginning of a line. What did it do? Try to find out what this character does. - - An octothorpe made ruby ignore the code following it. +#Study Drills +#1. Make your script print another line. + #- I added "puts 'This is another line.'" at the very end. +#2. Make your script print only one of the lines. + #- I used an octothorpe to in front of each line except one. +#3. Put a # (octothorpe) character at the beginning of a line. What did it do? Try to find out what this character does. + #- An octothorpe made ruby ignore the code following it. From 6462e94de70d3d06dc68bffea9fc93889480cac8 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 16:39:48 -0600 Subject: [PATCH 43/50] update exercise 2 format --- section1/ex2.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/section1/ex2.rb b/section1/ex2.rb index 6e3a15fa..42fe0e7e 100644 --- a/section1/ex2.rb +++ b/section1/ex2.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise # A comment, this is so you can read your program later. # Anything after the # is ignored by ruby. @@ -9,12 +9,12 @@ puts "This will run." -Study Drills -1. Find out if you were right about what the # character does and make sure you know what it's called (octothorpe or pound character) - - I was right about the octothorpe. The symbol is used to make note in the code without disturbing it. The symbol tells ruby to ignore it and everything after in that line. -2. Take your ex2.rb file and review each line going backward. Start at the last line, and check each word in reverse against what you should have typed. +#Study Drills +#1. Find out if you were right about what the # character does and make sure you know what it's called (octothorpe or pound character) + #- I was right about the octothorpe. The symbol is used to make note in the code without disturbing it. The symbol tells ruby to ignore it and everything after in that line. +#2. Take your ex2.rb file and review each line going backward. Start at the last line, and check each word in reverse against what you should have typed. -3. Did you find more mistakes? Fix them. - - No -4. Read what you typed above out loud, including saying each character by its name. Did you find more mistakes? Fix them. - - No +#3. Did you find more mistakes? Fix them. + #- No +#4. Read what you typed above out loud, including saying each character by its name. Did you find more mistakes? Fix them. + #- No From d2c5af728d74ee3826219e47fad63d39e90ed029 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 16:40:15 -0600 Subject: [PATCH 44/50] update exercise 3 format --- section1/ex3.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/section1/ex3.rb b/section1/ex3.rb index b704d743..ddcc422f 100644 --- a/section1/ex3.rb +++ b/section1/ex3.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise #prints the statement so I know what the code/equation is doing puts "I will now count my chickens:" #the amount of hens and roosters(integer) are calculated by the equation below @@ -24,8 +24,8 @@ puts "Is it greater or equal? #{5.2 >= -2.0}" puts "Is it less or equal? #{5.2 <= -2.0}" -Study Drills -1. Above each line, use the # to write a comment to yourself explaining what the line does. -2. Remember in Exercise 0 when you started irb? Start irb this way again and, using the math operators, use Ruby as a calculator. -3. Find something you need to calculate and write a new .rb file that does it. -4. Rewrite ex3.rb to use floating point numbers so it's more accurate. 20.0 is floating point. +#Study Drills +#1. Above each line, use the # to write a comment to yourself explaining what the line does. +#2. Remember in Exercise 0 when you started irb? Start irb this way again and, using the math operators, use Ruby as a calculator. +#3. Find something you need to calculate and write a new .rb file that does it. +#4. Rewrite ex3.rb to use floating point numbers so it's more accurate. 20.0 is floating point. From 1b211785610db1596a5cdc518a3aa3b401ac7c58 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 16:40:41 -0600 Subject: [PATCH 45/50] update exercise 4 format --- section1/ex4.rb | 51 ++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 26 deletions(-) diff --git a/section1/ex4.rb b/section1/ex4.rb index 908b6ba2..5ebfb9b6 100644 --- a/section1/ex4.rb +++ b/section1/ex4.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise # the amount of cars in this scenario is 100 cars = 100 # the amount of space within the car for passengers is 4.0 in a car @@ -24,32 +24,31 @@ puts "We have #{passengers} to carpool today." puts "We need to put about #{average_passengers_per_car} in each car." -Study Drills +#Study Drills -```There are 100 cars available.``` -```There are only 30 drivers available.``` -```There will be 70 empty cars today.``` -```ex4.rb:14: undefined local variable or method "carpool_capacity" for - main:Object (NameError)``` +#```There are 100 cars available.``` +#```There will be 70 empty cars today.``` +#```ex4.rb:14: undefined local variable or method "carpool_capacity" for + #main:Object (NameError)``` -1. Explain this error in your own words. Make sure you use line numbers and explain why. - - In my own words I would say that you neglected to give a defined variable or a variable that was a float or integer. - - Say I printed this out but I neglected to define "carpool_capacity". It would look like this: - cars = 100 -space_in_a_car = 4.0 -drivers = 30 -passengers = 90 -cars_not_driven = cars - drivers -cars_driven = drivers -carpool_capacity = -average_passengers_per_car = passengers / cars_driven - - The puts "We can transport #{carpool_capacity} people today" would not go through. +#1. Explain this error in your own words. Make sure you use line numbers and explain why. + #- In my own words I would say that you neglected to give a defined variable or a variable that was a float or integer. + #- Say I printed this out but I neglected to define "carpool_capacity". It would look like this: + #cars = 100 +#space_in_a_car = 4.0 +#drivers = 30 +#passengers = 90 +#cars_not_driven = cars - drivers +#cars_driven = drivers +#carpool_capacity = +#average_passengers_per_car = passengers / cars_driven + #- The puts "We can transport #{carpool_capacity} people today" would not go through. -2. I used 4.0 for space_in_a_car, but is that necessary? What happens if its just 4? - - 4.0 and 4 are technically the same number, but 4 is an integer and 4.0 is a float. If you just use 4 the output will just be an integer. +#2. I used 4.0 for space_in_a_car, but is that necessary? What happens if its just 4? + #- 4.0 and 4 are technically the same number, but 4 is an integer and 4.0 is a float. If you just use 4 the output will just be an integer. -3. Remember that 4.0 is a floating point number. It's just a number with a decimal point, and you need 4.0 instead of just 4 so that it is floating point. -3. Write comments above each of the variable assignments. -4. Make sure you know what = is called (equals) and that its purpose is to give data (numbers, strings, etc.) names (cars_driven, passengers). -5. Remember that _ is an underscore character. -6. Try running ruby from the Terminal as a calculator like you did before, and use variable names to do your calculations. Popular variable names are also i, x, and j. +#3. Remember that 4.0 is a floating point number. It's just a number with a decimal point, and you need 4.0 instead of just 4 so that it is floating point. +#3. Write comments above each of the variable assignments. +#4. Make sure you know what = is called (equals) and that its purpose is to give data (numbers, strings, etc.) names (cars_driven, passengers). +#5. Remember that _ is an underscore character. +#6. Try running ruby from the Terminal as a calculator like you did before, and use variable names to do your calculations. Popular variable names are also i, x, and j. From f247771acfdd6aede0b2920ef29aba37ffe84b02 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 16:41:13 -0600 Subject: [PATCH 46/50] update exercise 5 format --- section1/ex5.rb | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/section1/ex5.rb b/section1/ex5.rb index 43879185..0d6c756f 100644 --- a/section1/ex5.rb +++ b/section1/ex5.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise myname = "Kaelin E. Sleevi" myage = 23 #not a lie in 2009 myheight = 175.26 #centimeters @@ -17,17 +17,17 @@ #this line is a little tricky, try to get it exactly right puts "If I add #{my_age}, #{my_height}, and #{my_weight} I get #{my_age + my_height + my_weight}." -Study Drills -1. Change all the variables so there is no my_ in front of each one. Make sure you change the name everywhere, not just where you used = to set them. +#Study Drills +#1. Change all the variables so there is no my_ in front of each one. Make sure you change the name everywhere, not just where you used = to set them. -2. Try to write some variables that convert the inches and pounds to centimeters and kilograms. Do not just type in the measurements. Work out the math in Ruby. -irb(main):004:0> 12 * 5 -=> 60 -irb(main):005:0> 2.54 * 69 -=> 175.26 -irb(main):006:0> +#2. Try to write some variables that convert the inches and pounds to centimeters and kilograms. Do not just type in the measurements. Work out the math in Ruby. +#irb(main):004:0> 12 * 5 +#=> 60 +#irb(main):005:0> 2.54 * 69 +#=> 175.26 +#irb(main):006:0> -irb(main):006:0> 135 * 0.454 -=> 61.29 -irb(main):007:0> +#irb(main):006:0> 135 * 0.454 +#=> 61.29 +#irb(main):007:0> From 76e5165058c9a28e288d80dfc6a44fd84654138c Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 16:41:38 -0600 Subject: [PATCH 47/50] update exercise 6 format --- section1/ex6.rb | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/section1/ex6.rb b/section1/ex6.rb index 1538d4e7..c94839a2 100644 --- a/section1/ex6.rb +++ b/section1/ex6.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise # this assigns the variable "types_of_people" to the number. That way you have 10 types of people for the equation types_of_people = 10 # this is assigning the variable "x" to a sting that includes the variable types_of_people to print as a statement @@ -27,15 +27,14 @@ # this action will print the strings assigned to w and e together. We know that because the two are being added together below. The addition of the two will print in the Terminal puts w + e -Study Drills -1. Go through this program and write a comment above each line explaining it. +#Study Drills +#1. Go through this program and write a comment above each line explaining it. -2. Find all the places where a string is put inside a string. - - Lines 5, 16, 17, and 21 -3. Are you sure there are only four places? How do you know? Maybe I like lying. - - Yes, the rest of the lines are just assigned to one string (there is not another defined variable within the other assignments) or are the action of puts and the variable assigned. -4. Explain why adding the two strings w and e with + makes a longer string. - - It is adding two defined variables that are defined with strings together into one output. -5. What happens when you change the strings to use ' (single-quote) instead of " (double-quote)? Do they still work? Try to guess why. - - It depends, in some cases here it will make no difference, but in the strings that include an apostrophe the single quotations will open and close the strings in the wrong places. It will not print the same. - +#2. Find all the places where a string is put inside a string. + #- Lines 5, 16, 17, and 21 +#3. Are you sure there are only four places? How do you know? Maybe I like lying. + #- Yes, the rest of the lines are just assigned to one string (there is not another defined variable within the other assignments) or are the action of puts and the variable assigned. +#4. Explain why adding the two strings w and e with + makes a longer string. + #- It is adding two defined variables that are defined with strings together into one output. +#5. What happens when you change the strings to use ' (single-quote) instead of " (double-quote)? Do they still work? Try to guess why. + #- It depends, in some cases here it will make no difference, but in the strings that include an apostrophe the single quotations will open and close the strings in the wrong places. It will not print the same. From 671007808a14724bfbe38babe967029243e9b127 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 16:42:08 -0600 Subject: [PATCH 48/50] update exercise 7 format --- section1/ex7.rb | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/section1/ex7.rb b/section1/ex7.rb index a8d431d8..5f9128d2 100644 --- a/section1/ex7.rb +++ b/section1/ex7.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise print "How old are you? " age = gets.chomp print "How tall are you? " @@ -8,20 +8,20 @@ puts "So, you're #{age} old, #{height} tall and #{weight} heavy." -Study Drills -1. Go online and find out what Rubys gets.chomp does. - - I found that the "gets" creates a new line and asks the user to input a integer, variable, float, etc. and gets.chomp does the same thing except that it does not create a new line. gets.chomp allows a user to input as well as "gets", but there will not be a new line that is added after the string. +#Study Drills +#1. Go online and find out what Rubys gets.chomp does. + #- I found that the "gets" creates a new line and asks the user to input a integer, variable, float, etc. and gets.chomp does the same thing except that it does not create a new line. gets.chomp allows a user to input as well as "gets", but there will not be a new line that is added after the string. -2. Can you find other ways to use it? Try some of the samples you find. -You can use it ask questions to the user, play a game or run through the game play, you can use it to have users put their own information into the code. +#2. Can you find other ways to use it? Try some of the samples you find. +#You can use it ask questions to the user, play a game or run through the game play, you can use it to have users put their own information into the code. -3. Write another "form" like this to ask some other questions. +#3. Write another "form" like this to ask some other questions. -print "What is your favorite food?" -food = gets.chomp -print "What dessert do you like?" -dessert = gets.chomp -print "What would you like to drink?" -drink = gets.chomp +#print "What is your favorite food?" +#food = gets.chomp +#print "What dessert do you like?" +#dessert = gets.chomp +#print "What would you like to drink?" +#drink = gets.chomp -puts "So, you like #{food}, you would like #{dessert} and want #{drink} for a drink." +#puts "So, you like #{food}, you would like #{dessert} and want #{drink} for a drink." From 3e558d2ccfdda7b1024460927a4feff4e7dacd78 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 17:02:51 -0600 Subject: [PATCH 49/50] update format for section 2 exercises and drills --- section2/exercises/ex29.rb | 16 +++--- section2/exercises/ex30.rb | 36 ++++++------ section2/exercises/ex31.rb | 4 +- section2/exercises/ex32.rb | 110 ++++++++++++++++++------------------- 4 files changed, 83 insertions(+), 83 deletions(-) diff --git a/section2/exercises/ex29.rb b/section2/exercises/ex29.rb index cacdb1e1..2170f6a9 100644 --- a/section2/exercises/ex29.rb +++ b/section2/exercises/ex29.rb @@ -35,11 +35,11 @@ puts "People are dogs." end -1. Why does the code under the if need to be indented two spaces? - - The if creates a branch and that branch is the code under it. That way when we enter in the variable or change it, the code under is able to tell us if it is true or not. -2. What happens if it isn't indented? - - It is done so that you and other people know that is a block of code. -3. Can you put other boolean expressions from Exercise 27 in the if-statement? Try it. - - Yes -4. What happens if you change the initial values for people, cats, and dogs? - - Different statements will be true or false depending on the value change and the if statements. +#1. Why does the code under the if need to be indented two spaces? + #- The if creates a branch and that branch is the code under it. That way when we enter in the variable or change it, the code under is able to tell us if it is true or not. +#2. What happens if it isn't indented? + #- It is done so that you and other people know that is a block of code. +#3. Can you put other boolean expressions from Exercise 27 in the if-statement? Try it. + #- Yes +#4. What happens if you change the initial values for people, cats, and dogs? + #- Different statements will be true or false depending on the value change and the if statements. diff --git a/section2/exercises/ex30.rb b/section2/exercises/ex30.rb index 515f4770..27a3edb0 100644 --- a/section2/exercises/ex30.rb +++ b/section2/exercises/ex30.rb @@ -30,23 +30,23 @@ puts "Fine, let's stay home then." end -1. Try to guess what elsif and else are doing. - - I would guess elsif is being used or is giving a second possibilty for another true or false statement. Else is a third option if neither the if or elsif statements are true. -2. Change the numbers of cars, people, and trucks, and then trace through each if-statement to see what will be printed. - - If people is changed to 50 the printed would be: - - "We should not take the cars." - - "Maybe we could take the trucks." - - "Alright, let's just take the trucks" - - If cars is changed to 10 the printed would be: - - "We should not take the cars." - - "That's too many trucks." - - "Alright, let's just take the trucks." - - If trucks changed to 30 the printed would be: - - "We should take the cars." - - "Maybe we could take the trucks." - - "Fine, let's stay home then." -3. Try some more complex boolean expressions like cars > people || trucks < cars. - - if cars > people || trucks < cars +#1. Try to guess what elsif and else are doing. + #- I would guess elsif is being used or is giving a second possibilty for another true or false statement. Else is a third option if neither the if or elsif statements are true. +#2. Change the numbers of cars, people, and trucks, and then trace through each if-statement to see what will be printed. + #- If people is changed to 50 the printed would be: + #- "We should not take the cars." + #- "Maybe we could take the trucks." + #- "Alright, let's just take the trucks" + #- If cars is changed to 10 the printed would be: + #- "We should not take the cars." + #- "That's too many trucks." + #- "Alright, let's just take the trucks." + #- If trucks changed to 30 the printed would be: + #- "We should take the cars." + #- "Maybe we could take the trucks." + #- "Fine, let's stay home then." +#3. Try some more complex boolean expressions like cars > people || trucks < cars. + if cars > people || trucks < cars puts "Let's just take the cars." elsif cars < people || trucks > cars puts "Alright, let's take the trucks" @@ -54,4 +54,4 @@ puts "Let's stay home." end -4. Above each line write an English description of what the line does. +#4. Above each line write an English description of what the line does. diff --git a/section2/exercises/ex31.rb b/section2/exercises/ex31.rb index a49cd553..9361a26e 100644 --- a/section2/exercises/ex31.rb +++ b/section2/exercises/ex31.rb @@ -38,7 +38,7 @@ puts "You stumble around and fall on a knife and die. Good job!" end -1. Make new parts of the game and change what decisions people can make. Expand the game out as much as you can before it gets ridiculous. +#1. Make new parts of the game and change what decisions people can make. Expand the game out as much as you can before it gets ridiculous. puts "You enter a dark room with two doors. Do you go through door #1 or door #2?" print "> " @@ -83,7 +83,7 @@ puts "You stumble around and fall on a knife and die. Good job!" end -2. Write a completely new game. Maybe you don't like this one, so make your own. This is your computer; do what you want. +#2. Write a completely new game. Maybe you don't like this one, so make your own. This is your computer; do what you want. puts "You are driving down the road at night and hit a fork. Do you drive down the left or right?" print "> " diff --git a/section2/exercises/ex32.rb b/section2/exercises/ex32.rb index b4e7ebf7..afc5b71c 100644 --- a/section2/exercises/ex32.rb +++ b/section2/exercises/ex32.rb @@ -1,18 +1,18 @@ -Exercises - -Use IRB to store values with each of the following variable names. Which names are good, which are actually invalid Ruby, and which are valid but go against Ruby style? -1. time_machine: - - This is a good variable, it gives a descripton of the variable and uses snake_case. -2. student_count_integer: - - This could be a good variable, but the "integer" part is not necessary. The student count will be an integer either way. You can make it shorter without the excess word. -3. homeworkAssignment - - This is a bad variable and is invalid in ruby. It uses camel_case rather than snake_case. It should be homework_assignment -4. 3_sections - - This is a bad variable and is invalid in ruby. To name your variable it can not be named starting with an interger. It should be three_sections. -4. top_ppl - - This is a bad variable and is invalid in ruby. The word "ppl" is an abbreviation rather than using "people". It should be top_people. - -String methods +#Exercises + +#Use IRB to store values with each of the following variable names. Which names are good, which are actually invalid Ruby, and which are valid but go against Ruby style? +#1. time_machine: + #- This is a good variable, it gives a descripton of the variable and uses snake_case. +#2. student_count_integer: + #- This could be a good variable, but the "integer" part is not necessary. The student count will be an integer either way. You can make it shorter without the excess word. +#3. homeworkAssignment + #- This is a bad variable and is invalid in ruby. It uses camel_case rather than snake_case. It should be homework_assignment +#4. 3_sections + #- This is a bad variable and is invalid in ruby. To name your variable it can not be named starting with an interger. It should be three_sections. +#4. top_ppl + #- This is a bad variable and is invalid in ruby. The word "ppl" is an abbreviation rather than using "people". It should be top_people. + +#String methods .split and .length irb(main):001:0> name = "Kaelin Elizabeth Sleevi" @@ -29,7 +29,7 @@ => ["one", "two", "three", "four", "five"] irb(main):007:0> -Combining strings and variables +#Combining strings and variables name = "Kaelin Elizabeth Sleevi" puts "Good morning," + name + "!" @@ -39,43 +39,43 @@ mood = "excited" puts "I am #{modifier * 3 + mood} for today's class" -Compare the methos list for proper string versus: -1. "hello".methods - - In the string method before, you would use the method attached to the variable, but not the variables assignment to a string. -2. "hello".methods.count - _ The mthod is again being attached to a string and not the variable that is assigned to the string. There are also two methods attached. -3. :hello.methods - - Uses a symbol as the vairable that is a broken down string. Yet aagin not assigning a method to the variable. -4. :hello.methods.count - - Uses a symbol as a variable and two methods again - -Repeating instructions -- 5. times do +#Compare the methos list for proper string versus: +#1. "hello".methods + #- In the string method before, you would use the method attached to the variable, but not the variables assignment to a string. +#2. "hello".methods.count + #- The mthod is again being attached to a string and not the variable that is assigned to the string. There are also two methods attached. +#3. :hello.methods + #- Uses a symbol as the vairable that is a broken down string. Yet aagin not assigning a method to the variable. +#4. :hello.methods.count + #- Uses a symbol as a variable and two methods again + +#Repeating instructions + 5. times do puts "Hello,World!" end - - Hello,World! - Hello,World! - Hello,World! - Hello,World! - Hello,World! -Above is also an example of a ruby block. It has a command, and output, and an end. Usually starting with do. + #- Hello,World! + #Hello,World! + #Hello,World! + #Hello,World! + #Hello,World! +#Above is also an example of a ruby block. It has a command, and output, and an end. Usually starting with do. -Arrays in code ---- --- --- +#Arrays in code + --- --- --- | || || | ---- --- --- + --- --- --- 0 1 2 -------------- --------- ---------- + ------------- --------- ---------- | "Breakfast" || "Lunch" || "Dinner" | -------------- --------- ---------- - 0 1 2 + ------------- --------- ---------- + 0 1 2 -------------- --------- ---------- ----------- + ------------- --------- ---------- ----------- | "Breakfast" || "Lunch" || "Dinner" || "Dessert" | -------------- --------- ---------- ----------- - 0 1 2 3 + ------------- --------- ---------- ----------- + 0 1 2 3 meals = ["Breakfast", "Lunch", "Dinner"] ["Breakfast", "Lunch", "Dinner"] @@ -86,15 +86,15 @@ meals.last "Dessert" -- (<<) shovel operator -- ([]) fetch the element at a specific point using the square brackets -- ```.last``` is a method to get the last of the Array +#- (<<) shovel operator +#- ([]) fetch the element at a specific point using the square brackets +#- ```.last``` is a method to get the last of the Array -Common array methods to try -- each -- collect -- first and last -- shuffle +#Common array methods to try +#- each +#- collect +#- first and last +#- shuffle irb(main):001:0> one = ["this", "is", "an", "array"] => ["this", "is", "an", "array"] @@ -112,7 +112,7 @@ => # irb(main):009:0> -Hashes practice +#Hashes practice irb(main):001:0> produce = {"grapes" => 221, "oranges" => 6, "carrots" => 12} => {"grapes"=>221, "oranges"=>6, "carrots"=>12} irb(main):002:0> produce.keys @@ -123,14 +123,14 @@ => {"grapes"=>221, "oranges"=>6, "carrots"=>12} irb(main):005:0> -Conditionals practice +#Conditionals practice irb(main):002:1* def water_status(minutes) irb(main):003:2* if minutes < 7 irb(main):004:2* puts "The water is not boiling yet." irb(main):005:2* elsif minutes == 7 -irb(main):006:2* puts "It's just barely boiling" +irb(main):006:2* puts "Its just barely boiling" irb(main):007:2* elsif minutes == 8 -irb(main):008:2* puts "It's boiling!" +irb(main):008:2* puts "Its boiling!" irb(main):009:2* else irb(main):010:2* puts "Hot! Hot! Hot!" irb(main):011:1* end From f7ad78861b18375a8b88a6e93caf7b2da3cc7736 Mon Sep 17 00:00:00 2001 From: Kaelin Sleevi Date: Sat, 18 Jun 2022 17:04:50 -0600 Subject: [PATCH 50/50] update format for section 3 exercises and drills --- section3/ex32_loops_arrays.rb | 18 ++++++++-------- section3/ex34_accessing_elements.rb | 30 +++++++++++++------------- section3/ex39_hashes.rb | 16 +++++++------- section3/ex40_in_a_hundreds_minutes.rb | 2 +- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/section3/ex32_loops_arrays.rb b/section3/ex32_loops_arrays.rb index 4d989318..f10ad307 100644 --- a/section3/ex32_loops_arrays.rb +++ b/section3/ex32_loops_arrays.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] @@ -22,11 +22,11 @@ elements.each {|i| puts "Element was: #{i}"} -Study Drills -1. Take a look at how you used (0..5) in the last for-loop. Look up Ruby's "range operator" (.. and ...) online to see what it does. - - A "range operator" is: A range represents an interval, a set of values with a beginning and an end. Values of a range can be numbers, characters, strings or objects. - - You can use the elipses in ruby that supports ranges in a variety of ways including ranges as: sequences, conditions, and intervals. -2. Change the first for number in the_count to be a more typical .each style loop like the others. - - I changes the line to "the_count.each do |number|" -3. Find the Ruby documentation on arrays and read about them. What other operations can you do besides the push function? Try <<, which is the same as push but is an operator. fruits << x is the same as fruits.push(x). - - You can use "<<" function in lieu of "push". There are also other operations that can be used to print certain parts of your list like: ".first", ".last", [2], ".sort", ".each", ".collect", and ".shuffle". +#Study Drills +#1. Take a look at how you used (0..5) in the last for-loop. Look up Ruby's "range operator" (.. and ...) online to see what it does. + #- A "range operator" is: A range represents an interval, a set of values with a beginning and an end. Values of a range can be numbers, characters, strings or objects. + #- You can use the elipses in ruby that supports ranges in a variety of ways including ranges as: sequences, conditions, and intervals. +#2. Change the first for number in the_count to be a more typical .each style loop like the others. + #- I changes the line to "the_count.each do |number|" +#3. Find the Ruby documentation on arrays and read about them. What other operations can you do besides the push function? Try <<, which is the same as push but is an operator. fruits << x is the same as fruits.push(x). + #- You can use "<<" function in lieu of "push". There are also other operations that can be used to print certain parts of your list like: ".first", ".last", [2], ".sort", ".each", ".collect", and ".shuffle". diff --git a/section3/ex34_accessing_elements.rb b/section3/ex34_accessing_elements.rb index 07ee91df..6ff3a105 100644 --- a/section3/ex34_accessing_elements.rb +++ b/section3/ex34_accessing_elements.rb @@ -1,4 +1,4 @@ -Exercises +#Exercises animals = ['bear', 'ruby', 'peacock', 'kangaroo', 'whale', 'platypus'] puts "The second (2nd) animal is at 1 and is a #{animals[1]}" @@ -19,22 +19,22 @@ puts "The sixth (6th) animal is at 5 and is a #{animals[5]}" puts "The animal at 5 is the 6th animal and is a #{animals[5]}" -Study Dirlls -1. With what you know of the difference between these types of numbers, can you explain why the year 2010 in "January 1, 2010," really is 2010 and not 2009? (Hint: you cannot pick years at random.) - - The year 2010 really is 2010 and not 2009 because the start of the century begins at a 2000 just like the arrays starting at 0 the century started at 0 as well. -2. Write some more arrays and work out similar indexes until you can translate them. - - meals = ['breakfast', 'lunch', 'dinner', 'desert'] +#Study Dirlls +#1. With what you know of the difference between these types of numbers, can you explain why the year 2010 in "January 1, 2010," really is 2010 and not 2009? (Hint: you cannot pick years at random.) + #- The year 2010 really is 2010 and not 2009 because the start of the century begins at a 2000 just like the arrays starting at 0 the century started at 0 as well. +#2. Write some more arrays and work out similar indexes until you can translate them. + meals = ['breakfast', 'lunch', 'dinner', 'desert'] - - puts "The first (1st) meal of the day is at 0 and is #{meals[0]}" - - puts "The meal at 0 is the 1st meal and is #{meals[0]}" + puts "The first (1st) meal of the day is at 0 and is #{meals[0]}" + puts "The meal at 0 is the 1st meal and is #{meals[0]}" - - puts "The second (2nd) meal of the day is at 1 and is #{meals[1]}" - - puts "The meal at 1 is the 2nd meal and is #{meals[1]}" + puts "The second (2nd) meal of the day is at 1 and is #{meals[1]}" + puts "The meal at 1 is the 2nd meal and is #{meals[1]}" - - puts "The third (3rd) meal of the day is at 2 and is #{meals[2]}" - - puts "The meal at 2 is the 3rd meal and is #{meals[2]}" + puts "The third (3rd) meal of the day is at 2 and is #{meals[2]}" + puts "The meal at 2 is the 3rd meal and is #{meals[2]}" - - puts "The fourth (4th) meal of the day is at 3 and is #{meals[3]}" - - puts "The meal at 3 is the 4th meal and is #{meals[3]}" + puts "The fourth (4th) meal of the day is at 3 and is #{meals[3]}" + puts "The meal at 3 is the 4th meal and is #{meals[3]}" -3. Use Ruby to check your answers. +#3. Use Ruby to check your answers. diff --git a/section3/ex39_hashes.rb b/section3/ex39_hashes.rb index 72e1821a..90ea6469 100644 --- a/section3/ex39_hashes.rb +++ b/section3/ex39_hashes.rb @@ -82,10 +82,10 @@ city ||= 'Does Not Exist' puts "The city for the state 'TX' is: #{city}" -Study Drills +#Study Drills -1. Do this same kind of mapping with cities and states/regions in your country or some other country. - -states = { +#1. Do this same kind of mapping with cities and states/regions in your country or some other country. + states = { 'Colorado' => 'CO', 'Illinois' => 'IL', 'Washington' => 'WA', @@ -120,8 +120,8 @@ puts "#{state} is abbreviated #{abbrev} and has city #{city}" end -2. Find the Ruby documentation for hashes and try to do even more things to them. - - kay = { +#2. Find the Ruby documentation for hashes and try to do even more things to them. + kay = { 'First name' => 'Kaelin', 'Last name' => 'Sleevi', 'Age' => 23, @@ -164,6 +164,6 @@ puts grades['Dorothy Doe'] puts grades['Timmy Doe'] -3. Find out what you can't do with hashes. A big one is that they do not have order, so try playing with that. - - Apparently, as of Ruby version 1.9 hashes maintain an order in which they are stored. But it can not tore data in a specific order. - - We also cannot rely on just an index number to look or call the hashes out, so we use keys. +#3. Find out what you can't do with hashes. A big one is that they do not have order, so try playing with that. + #- Apparently, as of Ruby version 1.9 hashes maintain an order in which they are stored. But it can not tore data in a specific order. + #- We also cannot rely on just an index number to look or call the hashes out, so we use keys. diff --git a/section3/ex40_in_a_hundreds_minutes.rb b/section3/ex40_in_a_hundreds_minutes.rb index 3a04567b..394adf43 100644 --- a/section3/ex40_in_a_hundreds_minutes.rb +++ b/section3/ex40_in_a_hundreds_minutes.rb @@ -1,4 +1,4 @@ -Exercise +#Exercise Hashes practice irb(main):001:0> produce = {"grapes" => 221, "oranges" => 6, "carrots" => 12}