Python math.remainder() Method

❮ Math Methods


Example

Return the remainder of x with respect to y:

# Import math Library
import math

# Return the remainder of x/y
print (math.remainder(9, 2))
print (math.remainder(9, 3))
print (math.remainder(18, 4))
Try it Yourself »

Definition and Usage

The math.remainder() method returns the remainder of x with respect to y.


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 remainder
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 »

❮ Math Methods

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.