programming-examples/python/Math/Create the fraction instances of decimal numbers.py

11 lines
260 B
Python
Raw Normal View History

2019-11-15 12:59:38 +01:00
iimport decimal
import fractions
values = [
decimal.Decimal('0.2'),
decimal.Decimal('0.7'),
decimal.Decimal('2.5'),
decimal.Decimal('3.0'),
]
for d in values:
print('{} = {}'.format(d, fractions.Fraction(d)))