Modulo

In Python, the percent sign (%) is known as the modulo operator.

A modulo calculation returns the remainder of the division between two numbers.

Example 1

Loading...

Because 12 is not evenly divisible by 5, the value of x is 2.

Example 2

Loading...

Because 10 is evenly divisible by 5, the value of y is 0.

Codebyte Example

Interested in helping build Docs? Read the Contribution Guide or share your feedback.

Learn Python on Codecademy