Python Modulus Operator

In Python, Arithmetic Modulus Operator takes two operands and returns the remainder of their integer division.

Syntax

The syntax to find the remainder in the division of numbers: a and b using Modulus Operator is

</>
Copy
a % b

The above expression returns a number.

Example

In the following program, we take two numbers: a, b; and find the remainder in the integer division a / b.

main.py

</>
Copy
a = 6
b = 4

result = a % b

print(result)

Output

2

Conclusion

In this Python Tutorial, we learned about Arithmetic Modulus Operator, its syntax, and usage, with examples.