Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Licence CC BY-NC-ND Thierry Parmentelat & Arnaud Legout Inria - UCA

exercice - niveau avancé

On se propose d’écrire une classe pour représenter les polynômes :

Note importante

Le système de correction automatique a besoin également que votre classe définisse son comportement vis-à-vis de repr() ; regardez les exemples pour voir la représentation choisie.

from corrections.cls_polynomial import exo_polynomial
exo_polynomial.example()
Loading...

# votre code

class Polynomial:
    
    def __init__(self, *coefs):
        ...
# correction
exo_polynomial.correction(Polynomial)
Loading...

# peut-être utile pour debugger ?
P00 = Polynomial()
P0 = Polynomial(0)
P1 = Polynomial(1)
P = Polynomial(3, 2, 1)
Q = Polynomial(1, 2)
R = Polynomial(3, 8, 5, 2)
P0 == P00 == P0 * P1
False
P * Q == R
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[6], line 1
----> 1 P * Q == R

TypeError: unsupported operand type(s) for *: 'Polynomial' and 'Polynomial'
P(10)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Cell In[7], line 1
----> 1 P(10)

TypeError: 'Polynomial' object is not callable