## Working out a remainder

The modulo operator (%) will work out the remainder left over when one value goes into another:

This will print:

30 / 6 gives 0. Because 6 goes into 30 exactly 5 times there is no remainder; so 0 is printed.

This would output:

30 / 7 gives 2. Because 7 goes into 30 4 times (28) it leaves a remainder of 2.

To check if a number is odd or even you can see if it leaves a remainder when divided by 2:

If you enter an even number (remainder of 0):

If you enter an odd number (remainder of 1):

**Try this practice question out when you have tried inputs first:**

Practice Task 1

1. A rollercoaster only lets people on in groups of 4. Use an input line to get the user to enter a number. Check if that number is directly divisible by 4. If it is then print “Perfect groups of four!” otherwise print “You will be broken up”.

## Calculations not working? Tick off these common errors:

Have you saved a calculation into a variable?

You can’t just calculate values and expect Python to save it automatically. You need a variable to save it into:

total = number1 * number2

Correct calculation symbols?

A common error is to use x instead of * to multiply and to use / instead of \ to divide.

price = 60 * 100

number3 = number1 / number2

Have you printed the calculation?

Don’t forget to print your new total variable!

total = 89+897

print(total)