Home

Math Operations

In the last lesson, you learned about different variable types, including numbers. Numbers can then be operated on, for example, with the basic operations, addition (+), subtraction (-), multiplication (*), division (/). Anything with quotations around are considered a string, therefore 10 can be operated on, while "10" can not.

More Details

Modulo (%) is another commonly used operation in programming. Modulo is the remainder after dividing two integers. For example, 17 divided by 5 is 3 with a remainder of 2, so 17 modulus 5 equals 2.

This is a common way to determine whether a number is even or odd, as any odd number modulus 2 will result in 1 and any even number modulus 2 will result in 0.

Try It Out!

Go to Replit
  • Input a number and add 3, multiply by 2 and subtract 7. Then print the result.
  • Take in a number and add 9, then print out the remainder when divided by 3.

Related Problems