The fmod method of the math module
The fmod
method of the math
module returns the remainder of a floating-point number. In the first parameter of the method, we specify the number to be divided (the dividend), in the second parameter - the number by which we divide the first (the divisor).
Syntax
import math
math.fmod(dividend, divisor)
Example
Let's take the remainder from dividing the number 10.8
by 3
:
import math
print(math.fmod(10.8, 3))
Result of code execution:
1.8000000000000007
Example
Now let's apply the fmod
method to the number -4.56
:
import math
print(math.fmod(-4))
Result of code execution:
-1.5599999999999996