How to convert float to fraction and get numerator and the denominator in Python

1 Answer

0 votes
from fractions import Fraction as frac


print(frac('13.45'))
print(frac('13.45').numerator)
print(frac('13.45').denominator)



'''
run:

269/20
269
20

'''

 



answered Jun 10, 2019 by avibootz

Related questions

2 answers 308 views
308 views asked Apr 11, 2019 by avibootz
3 answers 448 views
1 answer 268 views
...