Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

How to find the fractional and integer parts of x in a two-item tuple in Python?

How to find the fractional and integer parts of x in a two-item tuple in Python?                               


1 Answer
Jayashree

The method modf() returns the fractional and integer parts of x in a two-item tuple. Both parts have the same sign as x. The integer part is returned as a float. First item in tuple is fractional part

>>> import math
>>> math.modf(100.73)
(0.730000000000004, 100.0)
>>> math.modf(-5.55)
(-0.5499999999999998, -5.0)
Advertisements

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.