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

Kon Ham #428

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
18 changes: 9 additions & 9 deletions day_1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,21 +48,21 @@ This will open the day_1 directory in Atom. You should be able to see the direct

1. Check off the items below as you complete the steps you just read for each lesson. ***Remember to create a file containing your work for each lesson!***

- [ ] [A Good First Program](https://learnrubythehardway.org/book/ex1.html)
- [x] [A Good First Program](https://learnrubythehardway.org/book/ex1.html)

- [ ] [Comments in Code](https://learnrubythehardway.org/book/ex2.html)
- [x] [Comments in Code](https://learnrubythehardway.org/book/ex2.html)

- [ ] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html)
- [x] [Numbers and Math](https://learnrubythehardway.org/book/ex3.html)

- [ ] [Variables and Names](https://learnrubythehardway.org/book/ex4.html)
- [x] [Variables and Names](https://learnrubythehardway.org/book/ex4.html)

- [ ] [Strings](https://learnrubythehardway.org/book/ex5.html)
- [x] [Strings](https://learnrubythehardway.org/book/ex5.html)

- [ ] [More Strings](https://learnrubythehardway.org/book/ex6.html)
- [x] [More Strings](https://learnrubythehardway.org/book/ex6.html)

- [ ] [Asking for Input](https://learnrubythehardway.org/book/ex11.html)
- [x] [Asking for Input](https://learnrubythehardway.org/book/ex11.html)

- [ ] Have you created 7 `ex.rb` files with your code in them?
- [x] Have you created 7 `ex.rb` files with your code in them?

1. Work through the [Strings](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#3.-strings) and [Numbers](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#5.-numbers) sections from Ruby in 100 Minutes. For each of these sections, open an `irb` session by typing `irb` into your terminal and type in the code snippets provided.

Expand All @@ -80,7 +80,7 @@ Work through the files in the day_1/exercises directory. Complete them in this
## Questions
- Each day contains a questions.md file where you will answer questions about what you have learned.

Answer the day 1 questions within the questions.md file. The `.md` file extension refers to markdown formatting. Markdown is a simple markup language to help format your text. [This article](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) shows everything you need for basic markdown formatting.
Answer the day 1 questions within the questions.md file. The `.md` file extension refers to markdown formatting. Markdown is a simple markup language to help for mat your text. [This article](https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet) shows everything you need for basic markdown formatting.

## Save your work in Git

Expand Down
11 changes: 11 additions & 0 deletions day_1/ex1.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
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.'

# Study Drills
# puts "Another line."
puts "Only this line prints"
12 changes: 12 additions & 0 deletions day_1/ex11.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
print "How old are you? "
age = gets.chomp
print "How tall are you? "
height = gets.chomp
print "How much do you weigh? "
weight = gets.chomp

puts "So, you're #{age} old, #{height} tall and #{weight} heavy."

print "Tell me a random number: "
randomNumber = gets.chomp
puts "Thanks! Your random number was #{randomNumber}"
7 changes: 7 additions & 0 deletions day_1/ex2.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# This is a commented line

puts "This is not a commented line" # but I can comment after my Code

# puts "This will not show because I am putting my octothorp in front of my code"

puts "This will definitely run, assuming I've formatted correctly!"
35 changes: 35 additions & 0 deletions day_1/ex3.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This should print a string
puts "I will now count my chickens:"
# Lines 9 & 10 should print an interpolated string with a numerical result
# the + operator should return the sum of numbers
# the - operator should return the difference of numbers
# the * operator should return the product of numbers
# the / operator should return the quotient of numbers
# the % operator should return the remainder of numbers
puts "Hens #{25.0 + 30.0 / 6.0}"
puts "Roosters #{100.0 - 25.0 * 3.0 % 4.0}"

# This should return a string
puts "Now I will count the eggs:"
# This should return a numberical value
puts 3.0 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6

# This should return a string
puts "Is it true that 3 + 2 < 5 - 7?"

# This should return a boolean value of either true or false
puts 3.0 + 2 < 5 - 7

# Lines 24 & 25 should return a string interpolated with a numerical result
puts "What is 3 + 2? #{3.0 + 2}"
puts "What is 5 - 7? #{5.0 - 7}"

# This should return a string
puts "Oh, that's why it's false."
# More strings
puts "How about some more."

# LInes 33-36 should return an interpolated string with boolean results of true or false
puts "Is it greater? #{5.0 > -2}"
puts "Is it greater or equal? #{5.0 >= -2}"
puts "Is it less or equal? #{5.0 <= -2}"
5 changes: 5 additions & 0 deletions day_1/ex3_study_drill.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# This should calculate the square footage of my room
# My room is 14ft by 16ft.
# Area is calculated Length * Width

puts "Your room's total area is #{14 * 16} ft. squared. Have a nice day!"
30 changes: 30 additions & 0 deletions day_1/ex4.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# defined variable cars and assigned it to numerical value of 100
cars = 100
# defined variable space_in_a_car and assigned it to number value of 4
space_in_a_car = 4
# defined variable driver and assigned it to number value of 30
drivers = 30
# defined variable passengers and assigned it to number value of 90
passengers = 90
# defined variable cars_not_driven to be equal to the value of the difference between the variables cars and drivers
cars_not_driven = cars - drivers
# cars_driven variable is assigned to the numerical value assigned to drivers, which is 30
cars_driven = drivers
# carpool_capacity variable is assigned to the numerical result of the product of the variables cars_driven and space_in_a_car
carpool_capacity = cars_driven * space_in_a_car
# average_passengers_per_car is assigned to the numerical value of the quotient of passengers and cars_driven
average_passengers_per_car = passengers / cars_driven

puts "There are #{cars} cars available"
puts "There are only #{drivers} drivers available"
puts "There will be #{cars_not_driven} empty cars today."
puts "We can transport #{carpool_capacity} people today."
puts "We have #{passengers} to carpool today."
puts "We need to put about #{average_passengers_per_car} in each car."

# Study Drills
# Error Message - Ruby shows an error at line 14 that the variable carpool_capacity was not appropriately defined
# 1. Your carpool_capacity number changes to an integer as a result of changing the number at space_in_a_car
# 4. In our case, the "=" operator is not necessarily the same value of the mathematical operator of "=".
# In our case, instead of being "equals", the "=" operator is instead to represent being "assigned". Hence, we use
# the "=" operator to assign variables to data types or to other variables or anything, really.
26 changes: 26 additions & 0 deletions day_1/ex5.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name = 'Zed A. Shaw'
age = 35 # not a lie in 2009
height = 74 # inches
weight = 180 # lbs
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'

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

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

# This should convert inches to centimeters
inches = 5
pounds = 25

makeToCentimeter = "You have #{inches} inches and when it's converted to centimeters you get #{inches * 2.54}cm"
puts makeToCentimeter
makeToPounds = "You have #{pounds} pounds and when it's converted to kilograms you get #{pounds * 0.453592}kg"
puts makeToPounds
48 changes: 48 additions & 0 deletions day_1/ex6.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# variable types_of_people is assigned to the value of 10
types_of_people = 10
# variable x is assigned to an interpolated string
x = "There are #{types_of_people} types of people."
# variable binary is assigned to a string
binary = "binary"
# variable do_not is assigned to a string
do_not = "don't"
# y variable is assigned to an interpolated string
y = "Those who know #{binary} and those who #{do_not}."

# prints to the console of the data assigned to the variable x
puts x
# prints to the console of the data assigned to the variable y
puts y

# prints to the console an interpolated string
puts "I said: #{x}."
# prints to the console an interpolated string
puts "I also said: '#{y}'."

# variable hilarious is assigned to the boolean data type of false
hilarious = false
# variable joke_evaluation is assigned to an interpolated string that
# also calls back another data type assigned to the hilarious variable
joke_evaluation = "Isn't that joke so funny?! #{hilarious}"

# returns to the console the data assigned to the variable joke_evaluation
puts joke_evaluation

# w variable is assigned to a string data type
w = "This is the left side of..."
# e variable is assigned to a string data type
e = "a string with a right side."

# prints to the console the interpolated result of the variables w and e
puts w + e

# Study Drills
# 3. There are 6 places that a string is inside a string. 5 if you don't include
# one line of code that has two instances of a string inside of a string.
# 4. Both w & e are variables with strings assigned to each variable. That's why
# calling a put to w & e will return in a longer string.
# 5. Sometimes putting a single quotation instead of a double quotation will cause
# problems because of the English syntax use of apostrophes, which utilize single
# quotes. The computer, because it reads both single and double quotes as strings,
# becomes confused when the human programmer "interpolates" English syntax useage
# of single and double quotes.
4 changes: 2 additions & 2 deletions day_1/exercises/interpolation.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
speedy = "quick red fox"
slow_poke = "lazy brown dog"

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

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

# YOUR CODE HERE
p "In a predictable result, the #{slow_poke} beat the #{speedy}"
8 changes: 6 additions & 2 deletions day_1/exercises/loops.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,18 @@

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

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

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

10.times do
p 'She sells seashells down by the seashore'
end
6 changes: 3 additions & 3 deletions day_1/exercises/numbers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
p 2 + 2

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

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

# Write code that prints the result of the modulo of 10 into 54:
# YOUR CODE HERE
p 54 % 10
4 changes: 2 additions & 2 deletions day_1/exercises/strings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
p "Alan Turing"

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

# Write code that prints `99 bottles of pop on the wall...` to the terminal:
# YOUR CODE HERE
p "99 bottles of pop on the wall..."
13 changes: 7 additions & 6 deletions day_1/exercises/variables.rb
Original file line number Diff line number Diff line change
@@ -1,29 +1,30 @@
# In the below exercises, write code that achieves
# the desired result. To check your work, run this
# file by entering the following command in your terminal:
# file by entering the following command in your terminal:
# `ruby day_1/exercises/variables.rb`

# Example: Write code that saves your name to a variable and
# prints what that variable holds to the terminal:
name = "Harry Potter"
name = "Kon Ham"
p name

# 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
string_harry = "Harry Potter must not return to Howarts!"
p stringHarry

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

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

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

I would write `puts "Hello World!"`

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

The `#`, or octothorp, is utilized to insert comments into a ruby file.

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

Integers have no floating decimal. That is, Any number without any decimal. Floats will have a decimal.

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

`animal = "zebra"`

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

`puts animal`

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

Interpolation allows me to insert variables into a string. For example,

```
variable = "Hello"
puts "#{variable}, my name is Kon"
```

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

The `gets` method gets input from a user.

1. Name and describe two common string methods:

The first common string method would be the `.split` method. This allows the user to take a string that split that string into smaller pieces.

Another common string method would be the `.length` method. This method will return a numerical value of the length of the string you are called in the method.
6 changes: 3 additions & 3 deletions day_2/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ Using your terminal, open your local copy of the forked repository you created d
1. Work through the [Arrays](http://tutorials.jumpstartlab.com/projects/ruby_in_100_minutes.html#7.-arrays) section of Ruby in 100 Minutes. As you work through this section, research each of the methods mentioned by looking through the [Ruby docs for Arrays](https://ruby-doc.org/core-2.4.1/Array.html). Documentation like this might look intimidating, but diving in and practicing now will build your comfort level. Create a file in your day_2 directory called `array_methods.md` and describe what each method does in your own words.
1. Work through the following lessons. Any files that you create while working can be kept in today's `exercises` directory.

- [ ] Turing's [Iteration and Each](http://backend.turing.io/module1/lessons/iteration_and_each) lesson.
- [x] Turing's [Iteration and Each](http://backend.turing.io/module1/lessons/iteration_and_each) lesson.

- [ ] [Booleans](https://learnrubythehardway.org/book/ex27.html) from Learn Ruby the Hard Way.
- [x] [Booleans](https://learnrubythehardway.org/book/ex27.html) from Learn Ruby the Hard Way.

- [ ] [Boolean Practice](https://learnrubythehardway.org/book/ex28.html) from Learn Ruby the Hard Way.
- [x] [Boolean Practice](https://learnrubythehardway.org/book/ex28.html) from Learn Ruby the Hard Way.

1. Work through the exercise files in the day_2/exercises directory. Complete them in this order:
1. arrays
Expand Down
Loading