Practice With Arithmetic Operators

Practice these programming examples to internalize these concepts.

6. Modulo

The % operator is the modulo, which returns the remainder rather than the quotient after division. This is useful for finding numbers that are multiples of the same number, for example.

Let's look at the modulo in action:

o = 85
p = 15
print(o % p)


To break this down, 85 divided by 15 returns the quotient of 5 with a remainder of 10. The value 10 is what is returned here because the modulo operator returns the remainder of a division expression.

If we use two floats with the modulo, a float value will be returned for the remainder:

q = 36.0
r = 6.0
print(o % p)



In the case of 36.0 divided by 6.0, there is no remainder, so the value of 0.0 is returned.