programming-examples/python/Math/Display the fraction instances of the string representation of a number.py

5 lines
141 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
import fractions
for s in ['0.7', '2.5', '9.32', '7e-1']:
f = fractions.Fraction(s)
print('{0:>4} = {1}'.format(s, f))