import fractions
import decimal
dec = [decimal.Decimal('0.1'),
decimal.Decimal('0.5'),
decimal.Decimal('1.0'),
decimal.Decimal('1.5'),
decimal.Decimal('3.14'),]
for d in dec:
print('{} = {}'.format(d, fractions.Fraction(d)))
'''
run:
0.1 = 1/10
0.5 = 1/2
1.0 = 1
1.5 = 3/2
3.14 = 157/50
'''