让我们回到小学刚刚学习分数的时候 :
from fractions import Fraction
a = Fraction(5,4)
b = Fraction(7,16)
print(a + b)
27/16
print(a *b)
35/64
c = a*b
c.numerator
35
c.denominator
64
float(c)
0.546875
让我们回到小学刚刚学习分数的时候 :
from fractions import Fraction
a = Fraction(5,4)
b = Fraction(7,16)
print(a + b)
27/16
print(a *b)
35/64
c = a*b
c.numerator
35
c.denominator
64
float(c)
0.546875