import fractions print(fractions.Fraction(1.5)) print(fractions.Fraction(5)) print(fractions.Fraction(1,3))
from fractions import Fraction frac = Fraction(1, 2)