5330 shaares
5 private links
5 private links
Tiens marrant, il y a un module python en natif pour simplifier les fractions.
In [24]: from fractions import Fraction
In [27]: Fraction(2, 8)
Out[27]: Fraction(1, 4)
In [28]: print Fraction(2, 8)
1/4
In [29]: print str(int(Fraction(2, 8)))
0
In [30]: print str(float(Fraction(2, 8)))
0.25