Python math.remainder() Method
Example
Find the value n that makes x completely divisible by y:
# Import math Library
import math
# Find the value n that makes x
completely divisible by y
print (math.remainder(9, 2))
print
(math.remainder(17, 4))
Try it Yourself »
Definition and Usage
The math.remainder()
method returns the closest value that can make numerator completely divisible by the denominator (positive or negative).
Note: This method does not return the remainder when a number is divided by another number. For that, we have math.fmod()
method.
Note: The divisor must be a non-zero number.
Syntax
math.remainder(x, y)
Parameter Values
Parameter | Description |
---|---|
x | Required. The number you want to divide. |
y | Required. The number you want to divide with. It must be a non-zero number, or a ValueError occurs. |
Technical Details
Return Value: | A float value, representing the number that makes numerator complete |
---|---|
Python Version: | 3.7 |
More Examples
Example
Return the remainder of x/y:
print (math.remainder(23.5, 5))
print
(math.remainder(23, 5.5))
print (math.remainder(12.5, 2.5))
print
(math.remainder(12, 2))
Try it Yourself »