Created
April 13, 2015 20:10
-
-
Save janetferguson/868fa2db209fb7b67346 to your computer and use it in GitHub Desktop.
Exercise 22
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
# False if/else statement | |
if 5 + 4 == 8 | |
puts "this is true" | |
else | |
puts "this is false" | |
end | |
# True if/else statement | |
if 2 * 2 >= 3 | |
puts "this is true" | |
else | |
puts "this is false" | |
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
def choose | |
puts "Do you like programming? Yes or no please." | |
choice = gets.chomp | |
if (choice.downcase == "yes") | |
puts "That\'s great!" | |
elsif (choice.downcase == "no") | |
puts "That\'s too bad!" | |
else | |
puts "That wasn\'t a yes or no." | |
end | |
end | |
choose | |
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
# 3.times do | |
# puts "Hello!" | |
# end | |
# number = 0 | |
# while (number <= 10) do | |
# p "the number is now #{number}" | |
# number += 1 | |
# end | |
(0..10).each do |n| | |
p "the new number is #{n}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment