Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Becky Nisttahuz #157

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions section1/calculations_ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#Print sentence 'I will now calculate Felipe's pay:'
puts "I will now calculate Felipe's sales:"
#Print the calculation in curly brackets
puts "Felipe's sales on weekdays for a month #{30 + 20 - 3 % 5 / 4}"
#Print the result of the calculation in curly brackets
puts "Felipe's sales on weekends for a month #{3 + 76 / 7}"
#Print sentence 'Now let's count his expenses:'
puts "Now let's count his expenses:"
#Print result of the calculation
puts 4 + 5 + 7 - 8 / 12
#Print question. Boolean
puts "It is true that #{30 + 20 - 3 % 5 / 4} + #{3 + 76 / 7} > #{ 4 + 5 + 7 - 8 / 12}?"
#Calculate and print the boolean answer. Either true or false
puts (30 + 20 - 3 % 5 / 4) + (3 + 76 / 7) > 4+ 5 + 7 - 8 / 12
#Print question and answer for the calculation in curly brackets
puts "What is 50 + 13? #{50 + 13}"
#Print question and answer for the calculation in curly brackets
puts "What is 4 + 5 + 7 - 8 / 12? #{4 + 5 + 7 - 8 / 12}"
#Print sentence 'Oh, now I understand.'
puts "Oh, now I understand."
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false
puts "Is it greater? #{50 + 13 > 4 + 5 + 7 - 8 / 12}"
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false
puts "Is it greater or equal? #{50 + 13 >= 4 + 5 + 7 - 8 / 12}"
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false
puts "Is it less or equal? #{50 + 13 <= 4 + 5 + 7 - 8 / 12}"
17 changes: 17 additions & 0 deletions section1/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# puts "Hello World!"
#puts "Hello Again"
#puts "I like typing this."
#puts "This is fun."
puts "Yay! Printing."
#puts "I'd much rather you 'not'."
#puts 'I "said" do not touch this.'
#puts "Making my script print another line"
# Making my script print only one of the lines: I use # at the beggining of each line but one
#puts "This is another line. What does putting a # character at the beginning of the line do? It makes it into a comment. It won't print.


#Study drills
#1. # Making my script print only one of the lines: I use # at the beggining of each line but one
#puts "This is another line. #What does putting a # character at the beginning of the line do? It makes it into a comment. It won't print.
#2. I made my script print only one of the lines by using the octothorpecharacter at the beginning of each line
#3. It comments out the line.
18 changes: 18 additions & 0 deletions section1/ex2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# 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."




#Study Drills
#1. I was right about what the octothorpe character does at the beginning of a line. It makes the line into a comment that won't print.
#2. I reviewed each line going backward.
#3. I fixed a couple of mistakes.
#4. I read out loud what I typed and did not find more errors
36 changes: 36 additions & 0 deletions section1/ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#Print sentence 'I will now count my chickens:'
puts "I will now count my chickens:"
#Print the calculation in curly brackets for hens
puts "Hens #{25.0 + 30.5 / 6.5}"
#Print the result of the calculation in curly brackets for roosters
puts "Roosters #{100.2 - 25.5 * 3.0 % 4.0}"
#Print sentence 'Now I will count the eggs:'
puts "Now I will count the eggs:"
#Print result of the calculation
puts 3.0 + 2.0 + 1.0 - 5.0 + 4.0 % 2.0 - 1.0 / 4.5 + 6.2
#Print question. Boolean
puts "It is true that 3.0 + 2.5 < 5.0 - 7.5?"
#Calculate and print the boolean answer. Either true or false
puts 3.0 + 2.5 < 5.0 - 7.5
#Print question and answer for the calculation in curly brackets
puts "What is 3.0 + 2.5? #{3.0 + 2.5}"
#Print question and answer for the calculation in curly brackets
puts "What is 5.0 - 7.5? #{5.0 - 7.5}"
#Print sentence 'Oh, thats why it's false.'
puts "Oh, thats why it's false."
#Print sentence 'How about some more.'
puts "How about some more."
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false
puts "Is it greater? #{5.5 > -2.5}"
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false
puts "Is it greater or equal? #{5.5 >= -2.5}"
#Print boolean question and answer for the calculation in curly brackets in boolean form: true or false
puts "Is it less or equal? #{5.5 <= -2.5}"

#Study drills
#1. used the octothorpe character (or pound) to write comments above each Line
#2. irb(main):001:0> p 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6
#7
#=> 7
#3. See calculations_ex3.#!/usr/bin/env ruby -wKU
#4. Rewrote ex3.rb and used floating point numbers.
55 changes: 55 additions & 0 deletions section1/ex4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# write a variable for number of cars
cars = 100
# write a variable for how many people fit in the car
space_in_a_car = 4.0
#write a variable for number of drivers
drivers = 30
# write a variable for number of passengers
passengers = 90
# write a variable for a calculation that tells us how many cars have not been driven
cars_not_driven = cars - drivers
# write a variable for cars driven
cars_driven = drivers
# write a variable for carpool capacity. It will be calculation: cars driven * space in a car
carpool_capacity = cars_driven * space_in_a_car
# # write a variable for average_passengers_per_car. It will be calculation: passengers / cars_driven
average_passengers_per_car = passengers / cars_driven

# Print sentence 'There are (number of cars) cars available.'
puts "There are #{cars} cars available."
# Print sentence 'There are only (number of drivers) drivers available.'
puts "There are only #{drivers} drivers available."
# Print sentence 'There will be (calculation of cars not driven) empty cars today.'
puts "There will be #{cars_not_driven} empty cars today."
# Print sentence 'We can transport (calculation of carpool capacity) people today.'
puts "We can transport #{carpool_capacity} people today."
# Print sentence 'We have (number of passengers) to carpool today.'
puts "We have #{passengers} to carpool today."
# Print sentence 'We need to put about (average of passengers per car) in each car.'
puts "We need to put about #{average_passengers_per_car} in each car."

#Study drills:

#ex4.rb:14: undefined local variable or method `carpool_capacity' for
#main:Object (NameError)
#You might have gotten a "NameError" message if your variable hadn't yet been assigned to anything.
#1. A floating number help us to have more accurate calculations. Just 4 would have worked also but it would't be a floating point number anymore.
#2. Yes, 4 is an integer, while 4.0 is a floating point number.
#3. Done
#4. The single equals (=) assigns a value to a variable.
#5. underscore character: (_)
#6. irb(main):002:0> irb
#irb#1(main):001:0> x = 5
#=> 5
#irb#1(main):002:0> i = 7
#=> 7
#irb#1(main):003:0> x + 7
#=> 12
#irb#1(main):004:0> j = 12
#=> 12
#irb#1(main):005:0> x % j / i
#=> 0
#irb#1(main):006:0> x % i
#=> 5
#irb#1(main):007:0> x % i * j
#=> 60
22 changes: 22 additions & 0 deletions section1/ex5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name = 'Zed A. Shaw'
age = 35 # not a lie in 2009
height = 74 * 2.54# inches converted to centimeters
weight = 180 / 2.2046 # lbs converted to kilograms
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'

puts "Let's talk about #{name}."
puts "He's #{height} centimeters tall."
puts "He's #{weight} kilograms heavy."
puts "Actually that's not too heavy."
puts "He's got #{eyes} eyes and #{hair} hair."
puts "His teeth are usually #{teeth} depending on the coffee."

# this line is tricky, try to get it exactly right
puts "If I add #{age}, #{height}, and #{weight} I get #{age + height + weight}."


#Study Drills
#1. I changed all the variables so there is no: my_
#2. I wrote some variables that convert the inches and pounds to centimeters and kilograms.
37 changes: 37 additions & 0 deletions section1/ex6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Create a (type of people) variable and set it to number 10
types_of_people = 10
# Set x to 'There are (type of people variable) types of people'
x = "There are #{types_of_people} types of people."
#Create a binary variable and set it to 'binary'
binary = "binary"
#Create a (do not) variable and set it to 'don't
do_not = "don't"
#Set y to 'Those who know (binary) and those who (do not).'
y = "Those who know #{binary} and those who #{do_not}."
#Print x
puts x
#Print y
puts y
#Print 'I said: x.'
puts "I said: #{x}."
#Print 'I also said: 'y'.'
puts "I also said: '#{y}'."
#Create variable hilararious and set it to false
hilarious = false
#Create variable (joke evaluation) and set it to 'Isn't that joke so funny?! (hilarious)'
joke_evaluation = "Isn't that joke so funny?! #{hilarious}"
#Print joke evaluation
puts joke_evaluation
#Set w to 'This is the left side of...'
w = "This is the left side of..."
#Set e to 'a string with a right side.'
e = "a string with a right side."
#Concatenate w and e
puts w + e

#Study Drills
#1. Used octothorpe character to make omments above each line explaining it.
#2. Found all the places where a string is put inside a string:4
#3. Yes, it was in 4 places
#4. Because we are concatenating the string
#5 They still work because uby knows when we want something to be a string when we use either double quotes or single quotes. We just need to pick one and be consistent.
22 changes: 22 additions & 0 deletions section1/ex7.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
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."


#Study drills
#1. It returns a new String with the given record separator removed from the end of the str
#2. To get a float input: gets.chomp.to_f and a integer input: gets.chomp.to_i
#3.
#print "Who are you? "
#name = gets.chomp
#print "What is your hobby? "
#hobby = gets.chomp
#print "Why you like doing that? "
#why_hobby = gets.chomp

#puts "So, you're #{name},you like #{hobby} and you like it because #{why_hobby}."
5 changes: 3 additions & 2 deletions section1/exercises/booleans.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
p 7 > 2

# YOU DO: log to the console the result of "hello" is equal to "Hello":

p "hello" === "Hello"
# YOU DO: log to the console the result of 3 is not equal to 4:

p 3 != 4
# YOU DO: log to the console the result of 4 is less than or equal to 5:
p 4 <= 5
8 changes: 6 additions & 2 deletions section1/exercises/interpolation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,20 @@
speedy = "quick red fox"
slow_poke = "lazy brown dog"

p # YOUR CODE HERE
p "The #{speedy} jumped over the #{slow_poke}"# YOUR CODE HERE

# Write code that uses the variables below to form a string that reads
# "In a predictable result, the tortoise beat the hare!":
slow_poke = "tortoise"
speedy = "hare"

# YOUR CODE HERE

p "In a predictable result, the #{slow_poke} beat the #{speedy}!"

# YOU DO:
# Declare three variables, name/content/data type of your choice. Think carefully about what you name the variables. Remember, the goal is to be concise but descriptive (it's a hard balance!) Then, log out ONE sentence that incorporates all THREE variables.
favorite_hobby = "salsa dancing"
day_of_week = "Saturday"
time_of_day = "night"

p "I really want to go #{favorite_hobby} on #{day_of_week} #{time_of_day}"
11 changes: 8 additions & 3 deletions section1/exercises/loops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,23 @@

# Example: Write code that prints your name five times:
5.times do
p "Hermione Granger"
p "Becky Nisttahuz"
end

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

# Write code that prints the phrase 'She sells seashells down by the seashore'
# ten times:
# YOUR CODE HERE

10.times do
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
5 changes: 3 additions & 2 deletions section1/exercises/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
p 2 + 2

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

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

p 6 * 53
# Write code that prints the result of the modulo of 10 into 54:
# YOUR CODE HERE
p 54 % 10
9 changes: 5 additions & 4 deletions section1/exercises/strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@
# `ruby section1/exercises/strings.rb`

# Example: Write code that prints your name to the terminal:
p "Alan Turing"
p "Becky Nisttahuz"

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

# Write code that prints `99 bottles of pop on the wall...` to the terminal:
# YOUR CODE HERE

# Write out code to log one line from your favorite song or movie.
p "99 bottles of pop on the wall..."
# Write out code to log one line from your favorite song or movie.
p "My precious."
Loading