This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screencast #7 | |
| puts "Welcome to the Brynn Quiz! What day of the week was Brynn born?" | |
| answer1 = gets.chomp | |
| puts "What year was Brynn born?" | |
| answer2 = gets.chomp | |
| puts "What is Brynn's middle name?" | |
| answer3 = gets.chomp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screencast #8 | |
| puts "Welcome to the Number Guessing Game!" | |
| puts "Guess a number between 1 and 100." | |
| the_right_answer = rand(100) | |
| tries = 1 | |
| 10.times do | |
| guess = gets.chomp.to_i | |
| if guess == the_right_answer | |
| puts "You won after " + tries.to_s + " tries!" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screencast #9 | |
| puts "Welcome! Please enter four words:" | |
| words = [] | |
| 4.times do | |
| puts "Enter word:" | |
| words << gets.chomp | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screencast #10 | |
| puts "Welcome! Please enter a word to be jumbled:" | |
| word = gets.chomp | |
| jumble = word.split("") | |
| puts "Here's your jumbled word:" | |
| puts jumble.shuffle.join |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Chapter 2 Exercises | |
| puts "Hours in a year?" | |
| puts 24*365 | |
| puts "Minutes in decade?" | |
| puts ((60*24)*365)*10 | |
| puts "How many seconds old am I?" | |
| puts (((33*365)*24)*60)*60 | |
| puts "How old is the authoer?" | |
| puts (((1160000000/60)/60)/24)/365 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screencast #11 | |
| puts "Hello, please enter six words, one at a time:" | |
| list = [] | |
| 6.times do | |
| list << gets.chomp | |
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screencast #12 | |
| Played around in irb, did a little searching on ruby-doc.org, and the only way I could figure out how to access a variable in an array that was in an array that was in an array was to .flatten the whole array, then call the variable based on index. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Screencast #13 | |
| state_capitals = {"Illinois" => "Springfield", "Hawaii" => "Honolulu", "Kansas" => "Topeka", "New York" => "Albany", "Maryland" => "Annapolis"} | |
| puts "Greetings! Please enter one of the following states to find out what the capital of that state is: Illinois, Hawaii, Kansas, New York or Maryland." | |
| state = gets.chomp.capitalize | |
| puts state_capitals[state] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Chapter 5 FullNameGreeting | |
| puts "Hello! What's your first name?" | |
| first_name = gets.chomp | |
| puts "What's your middle name?" | |
| middle_name = gets.chomp |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Chapter 5 BiggerBetterNumber | |
| puts "Ahoy matey, what's yer favorite number?" | |
| fav_num = gets.chomp | |
| better_num = fav_num.to_i + 1 | |
| better_num_string = better_num.to_s | |
| puts "That be nice, but " + better_num_string + " would suit ya better." |
OlderNewer