Python Tutorial Python Advanced Python References Python Libraries

Python math - modf() Function



The Python math.modf() function returns the fractional and integral parts of a given number. Both parts carry the sign as x and are floats.

Syntax

math.modf(x)

Parameters

x Required. Specify the number.

Return Value

Returns the fractional and integral parts of x.

Example:

The example below shows the usage of modf() function.

import math

print(math.modf(10.55))
print(math.modf(-10.55))

The output of the above code will be:

(0.5500000000000007, 10.0)
(-0.5500000000000007, -10.0)

❮ Python Math Module