Facebook Page Twitter Page LinkedIn Page
× Python Tutorial Python Advanced Python Resources Python Libraries

The Python math.remainder() function is used to compute the remainder operation on two arguments. The remainder can be expressed as follows:

Remainder = x - y * Q, where Q is the quotient of x/y rounded to the nearest integer. If x/y falls exactly at the midway between two integers, the even integer is returned.

In special cases it returns the following:

  • If x - y * Q is zero, the method returns +0 if x is positive and -0 if x is negative.


#New in version 3.7
math.remainder(x, y)   


x Required. Specify the dividend.
y Required. Specify the divisor.

Return Value

Returns the remainder when x is divided by y.


In the below example, remainder() function is used to calculate the remainder operation on two given arguments.

import math

print(math.remainder(10, 4))
print(math.remainder(14, 4))
print(math.remainder(60.8, 18.1))

The output of the above code will be:


❮ Python Math Module