Easy Tutorial
❮ Python Att Time Tzset Python String Count ❯

Python math.remainder() Method

Python math Module

The math.remainder(x, y) method in Python returns the remainder of x divided by y.

Python Version: 3.7

Syntax

The syntax for the math.remainder() method is as follows:

math.remainder(x, y)

Parameter Descriptions:

Return Value

A floating-point value, representing the remainder.

Example

The following example calculates the remainders:

Example

# Import math package
import math

# Remainder of x/y
print(math.remainder(9, 2))
print(math.remainder(9, 3))
print(math.remainder(18, 4))

print(math.remainder(23.5, 5))
print(math.remainder(23, 5.5))
print(math.remainder(12.5, 2.5))
print(math.remainder(12, 2))

Output:

1.0
0.0
2.0
-1.5
1.0
0.0
0.0

Python math Module

❮ Python Att Time Tzset Python String Count ❯