Home >>Python math Module >Python math.fmod() Method

Python math.fmod() Method

Python math.fmod() Method

Python math.fmod() method in python is used to returns modulus in float type of a specified number when a number is divided by another number and it accepts two arguments (the first parameter is known as dividend and the second parameter is known as divisor).

Syntax:
math.fmod(x, y)

Parameter Values

Parameter Description
X It is required a number to divide
Y It is required a number to divide with
Here is an example of Python math.fmod() Method:

import math
print (math.fmod(12, 2))
print (math.fmod(15, 8))
print (math.fmod(10, 10))

Output:
0.0
7.0
0.0
Example 2:

import math
x = 2
y = 7
result = math.fmod(x,y)
print("result = ", result)
x = 6
y = -9
result = math.fmod(x,y)
print("result = ", result)
x = 9.17
y = 6.25
result = math.fmod(x,y)
print("result = ", result)

Output:
result = 2.0
result = 6.0
result = 2.92

No Sidebar ads