Mar-16-2019, 08:48 AM
(Mar-15-2019, 10:51 PM)Skaperen Wrote: so fractions.Fraction(1.5) will give me 0.5?
Be careful, 1.5 is a string, so it should be defined appropriately, as follows. Cheers
# ----- frac.py --------- from fractions import Fraction print (Fraction('1.5')) # ------ OUTPUT --------- # C:\Training>python frac.py # 3/2 # -----------------------