Rational2

from fractions import Fraction import sys d = float(sys.argv[1]) f=d, Fraction.from_float(d).limit_denominator(1000) a=f[1] b=str(a) c=eval(b) print ("Decimal=",d) print ("Fraction:",a,"=",c) print ("Error=",c-d)
 * 1) !/usr/bin/python3