pythonnn Transcribed Image Text: Write a class called Quadratic, which implements a quadratic polynomial with integer coefficients

pythonnn Transcribed Image Text: Write a class called Quadratic, which implements a quadratic polynomial with integer coefficients. For
each quadratic polynomial ar? + br +c, an instance is generated like this: Quadratic(la, b, c]).
For two concrete examples, the instances P and Q of the class Quadratic, where P represents the poly-
nomial 3r? – 7z +5 and Q represents the polynomial r? + 8z – 3, are defined as
P = Quadratic([3, -7, 5])
Q = Quadratic([1, 8, -3])
When printing an instance, for example P, print(P) should display 3z^2 – 7z + 5 on the screen.
In addition, write the following class methods which manipulate the instances of the class Quadratic.
roots(), which is called in the main function as P.roots(), and returns the two roots of the polynomial P
inside a list. For P, P.roots() returns [1.16667+0.55277i, 1.16667+0.55277i]. For the instance Q, Q.roots
returns [0.35890+0i, -8.3589+0Oi], since Q has only two real roots. If a polynomial has a double root,
return the list containing the same root twice in the same way as for P and Q.

-25-


Buy plagiarism free, original and professional custom paper online now at a cheaper price. Submit your order proudly with us



Essay Hope