How to get numbers after decimal point? How to get numbers after decimal point? python python

How to get numbers after decimal point?


5.55 % 1

Keep in mind this won't help you with floating point rounding problems. I.e., you may get:

0.550000000001

Or otherwise a little off the 0.55 you are expecting.


Use modf:

>>> import math>>> frac, whole = math.modf(2.5)>>> frac0.5>>> whole2.0


What about:

a = 1.3927278749291b = a - int(a)b>> 0.39272787492910011

Or, using numpy:

import numpya = 1.3927278749291b = a - numpy.fix(a)