Numbers Exercises

For these exercises, we’re only going to use IRB.

Remember: To run IRB, open a command line window (Powershell or Terminal). Then enter the command irb and press Enter.

To exit a running IRB, enter the command exit.

  1. Play around with numbers and their operators (addition, subtraction, multiplication, division)! For example, calculate your age from the year you were born in.
  2. What is special about the division operator?
  3. There is another operator we haven’t talked about yet. It’s called “modulo” and uses the % character. Try this in IRB: 8 % 3. What’s the result? Can you figure out what the operator does by experimenting with the numbers? If not, no problem, just google it!