Home »
Python
math.remainder() method with example in Python
Python math.remainder() method: Here, we are going to learn about the math.remainder() method with example in Python.
Submitted by IncludeHelp, on April 18, 2019
Python math.remainder() method
math.remainder() method is a library method of math module, it is used to find the remainder of given numbers, it accepts two numbers (integer or float) and returns the remainder of the first number with respect to the second number in the float.
Note: math.remainder() method is available in the new version of Python – Python 3.7
Syntax of math.remainder() method:
math.remainder(a, b)
Parameter(s): a, b – the numbers whose remainder needs to be calculated.
Return value: float – it returns a float value that is the remainder of a with respect to b.
Example:
Input:
a = 10
b = 7
# function call
print(math.remainder(a, b))
Output:
3.0
Python code to demonstrate example of math.remainder() method
# python code to demonstrate example of
# math.remainder() method
# importing math module
import math
# numbers
a = 10
b = 7
# finding remainder
print(math.remainder(a,b))
a = 10.2
b = 7.1
# finding remainder
print(math.remainder(a,b))
Output
3.0
3.0999999999999996