1.6. Correction du TP sur la mise en oeuvre d’une classe Fraction
class Fraction:
PRECISION = 0.0000001
def __init__(self, num, den):
if den:
self.__den = den
else:
raise ZeroDivisionError("denominator can't be zero")
self.__num = num
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[1], line 1
----> 1 f = Fraction(2,3)
NameError: name 'Fraction' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[2], line 1
----> 1 f
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[3], line 1
----> 1 print(f)
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[4], line 1
----> 1 f.numerateur
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[5], line 1
----> 1 f.egal(Fraction(4,6))
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[6], line 1
----> 1 f.egal(Fraction(4,5))
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[7], line 1
----> 1 f.somme(Fraction(4,5))
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[9], line 1
----> 1 g = f.inverse()
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[10], line 1
----> 1 type(g)
NameError: name 'g' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[11], line 1
----> 1 simplifier(Fraction(4,6))
NameError: name 'simplifier' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[12], line 1
----> 1 f
NameError: name 'f' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[13], line 1
----> 1 g = Fraction(4,5)
NameError: name 'Fraction' is not defined
---------------------------------------------------------------------------
NameError Traceback (most recent call last)
Cell In[14], line 1
----> 1 f + g
NameError: name 'f' is not defined