The modulo operation is an arithmetic operation that finds the remainder of the division of one number by another. The remainder is called the modulus of the operation.
For example, 5 divided by 3 equals 1, with a remainder of 2, and 8 divided by 4 equals 2, with a remainder of 0.

The modulo operation is an arithmetic operation that finds the remainder of the division of one number by another. The remainder is called the modulus of the operation.

For example, 5 divided by 3 equals 1, with a remainder of 2, and 8 divided by 4 equals 2, with a remainder of 0.

## Python Modulo Operator

In Python, the modulo operator is represented by the percent sign (`%`

). The syntax is as follows:

`num1 % num2`

Copy

Here is an example:

`5 % 4`

Copy

`1`

If the divisor (the second argument) is equal to zero a `ZeroDivisionError`

is raised:

`5 % 0`

Copy

`ZeroDivisionError: integer division or modulo by zero`

The modulo operator also accepts floating numbers as arguments:

`6.8 % 3.4`

Copy

`0.0`

When formatting strings, the `%`

character represents the interpolation operator.

python
python modulo