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 209 views
209 views asked Apr 11, 2019 by avibootz
3 answers 292 views
1 answer 185 views
...