The math.modf() function  is used to split a real number into its fractional and integer components.

Syntax:
math.modf(x)
copy

Where, parameter is the number to split.

The function returns a tuple containing the fractional and the integer parts of x.

ExampleEdit & Run
import math

>>> math.modf(2)
(0.0, 2)
>>> math.modf(4.5)
(0.5, 4.0)
>>> math.modf(5.8)
(0.7999999999999998, 5.0)
>>> math.modf(100.2)
(0.20000000000000284, 100.0)
>>> math.modf(3.142)
(0.1419999999999999, 3.0
>>> math.modf(math.e)
(0.7182818284590451, 2.0)
copy