python 3 float to fraction code example Example: python float to fraction >>> from fractions import Fraction >>> Fraction(0.25) Fraction(1, 4)