Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

Python math.remainder() Method

Python math.remainder() Method

Python math Module Python math Module

Python mathremainder(x, y) The method returns the remainder of x/y.

Python version: 3.7

Syntax

The syntax of the math.remainder() method is as follows:

math.remainder(x, y)

Parameter Description:

Return Value

A floating-point value returning the remainder.

Example

The following example computes the remainder:

Example

Import the math package

import

math

The remainder of x/y

print

(

math

.

remainder

(

9

,

2

)

)

print

(

math

.

remainder

(

9

,

3

)

)

print

(

math

.

remainder

(

18

,

4

)

)

print

(

math

.

remainder

(

23.5

,

5

)

)

print

(

math

.

remainder

(

23

,

5.5

)

)

print

(

math

.

remainder

(

12.5

,

2.5

)

)

print

(

math

.

remainder

(

12

,

2

)

)

Output result:



1.0

0.0

2.0

-1.5

1.0

0.0

0.0

Python math Module Python math Module