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 max (number1, number2) | |
if number1 > number2 | |
puts number1 | |
else | |
puts number2 | |
end | |
end | |
max(10,5) |
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
puts "Please enter your bill amount" | |
amount = gets.to_f | |
tip_percent = 0.20 | |
tip = amount * tip_percent | |
total = amount + tip | |
puts total |
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
puts"Question\n Let’s start with an easy one. Write the expression 1+1 in two different, but equivalent ways." | |
puts"Answer\n 1+(1),1.0+(1)" | |
puts"Question\n Assume someone buys a product from your website for $33.50. You don’t trust float money. Can you think of something you can do to help you keep track of that value?" | |
puts"Answer\n33.50*100.to_i" | |
puts"Question \nMost things in Ruby are “introspectable”, meaning you can find out what something is and what it can do. Introspection helps you learn the language. Even a list of methods is introspectable. For example, the list of methods has methods. Output the list of methods available on a list of methods. There should be a sort method in that list. What does it do?" | |
puts"Answer \nThe sort method puts whatever you are sorting in alphabetical order." | |
puts"Question \n Type a number large enough such that calling the “class” method returns Bignum rather than Fixnum. How many digits long was it?" | |
puts"Answer\nTwenty digits" | |
puts"Question\nIf you round -1.5, is the |
NewerOlder