Episode 3 - Code Flow: Left to Right

Exercises

  1. What do you think the output to this will be? Be sure to check your answer by running the code:
    puts 21 - 6 / 2 * 3
  2. Given this line of code:
    puts 100 * 5 - 2 / 2
    It will output 499. Just by adding parentheses, change the output to 150. DO NOT change any numbers or operators (*, -, / etc.)
  3. Let’s start with an error you might get by running your code:
    ZeroDivisionError: divided by 0
    What would be a line of code that would result in this error? Be sure to test it, and get the same error above.