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
| nums = [75, 100, 85, 65, 84, 87, 95] | |
| def average(nums) | |
| sum = 0 | |
| nums.each do |number| | |
| sum += number | |
| end | |
| sum/nums.length | |
| 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
| commit 1b60a793e9a74abba5eda41a265c58f011c661b5 | |
| Author: ewhitebloom <ewhitebloom@gmail.com> | |
| Date: Thu Feb 20 19:48:55 2014 -0500 | |
| Even more items added | |
| commit 191736b523c0cc14a191a5acc5fae586952d4a74 | |
| Author: ewhitebloom <ewhitebloom@gmail.com> | |
| Date: Thu Feb 20 19:47:32 2014 -0500 |
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
| favorite_movies = [ | |
| { title: 'The Big Lebowski', year_released: 1998, director: 'Joel Coen', imdb_rating: 8.2 }, | |
| { title: 'The Shining', year_released: 1980, director: 'Stanley Kubrick', imdb_rating: 8.5 }, | |
| { title: 'Troll 2', year_released: 1990, directory: 'Claudio Fragasso', imdb_rating: 2.5 } | |
| ] | |
| favorite_movies.each do |movie| | |
| puts "#{movie[:year_released]}: #{movie[:title]}" | |
| 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
| characters = { | |
| "Tyrion Lannister" => "House Lannister", | |
| "Jon Snow" => "Night's Watch", | |
| "Hodor" => "House Stark", | |
| "Stannis Baratheon" => "House Baratheon", | |
| "Theon Greyjoy" => "House Greyjoy" | |
| } | |
| characters.each do |key,value| | |
| puts key + " represents the " + value |
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
| def sales_price_loop | |
| input = nil | |
| totals = [] | |
| subtotal = 0 | |
| until input == "done" | |
| puts "What is the sale price?" | |
| unless input == "done" | |
| input = gets.chomp | |
| subtotal = tally(input, totals, subtotal) | |
| 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
| NUMBER = 673 | |
| message = print "Guess a number between 0 and 1000:" | |
| guess = gets.chomp.to_i | |
| until guess == NUMBER | |
| message = "Guess a number between 0 and 1000:" | |
| difference = NUMBER - guess | |
| if difference >= 0 | |
| puts "Too low, try again..." |
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
| light = 5 | |
| medium = 7.50 | |
| bold = 9.75 | |
| puts "How much money does the customer owe?" | |
| owed = gets.chomp.to_f | |
| puts "How much money did the customer give you?" |
NewerOlder