Python math.remainder() Method
Python mathremainder(x, y) The method returns the remainder of x/y.
Python version: 3.7
Syntax
The syntax of the math.remainder() method is as follows:
math.remainder(x, y)
Parameter Description:
- x -- required, the dividend.
- y -- optional, the divisor. Must be a non-zero number, otherwise a ValueError occurs.
Return Value
A floating-point value returning the remainder.
Example
The following example computes the remainder:
Example
Import the math package
import
math
The remainder of x/y
(
math
.
remainder
(
9
,
2
)
)
(
math
.
remainder
(
9
,
3
)
)
(
math
.
remainder
(
18
,
4
)
)
(
math
.
remainder
(
23.5
,
5
)
)
(
math
.
remainder
(
23
,
5.5
)
)
(
math
.
remainder
(
12.5
,
2.5
)
)
(
math
.
remainder
(
12
,
2
)
)
Output result:
1.0
0.0
2.0
-1.5
1.0
0.0
0.0
Python math Module