Objective
With __call__ an object can be called as if it were a function, and at the same time store data. It is useful for functions with configuration (a polynomial, a multiplier, a filter…).
Instructions
- Create the class
Polynomialthat receives the list of coefficients (from the highest degree to the lowest) and, when called withx, returns the value of the polynomial. - The first line has the coefficients; the second, the number
nof values; thennlines with an integerx. Showp(x) = value.
1 2 3
3
0
1
2
p(0) = 3
p(1) = 6
p(2) = 11
Open the editor in full screen: the statement on the left and your code, the output and the tests on the right.
Start exercise