Питон рациональные числа

from fractions import Fraction

Fraction("0.2").as_integer_ratio()
# (1, 5)
# so much better
Puzzled Puffin