Question: Write a Python class Polynomial which captures polynomials with integer coefficients. Your class must provide at least the following features: 1-a method to create a
Write a Python class Polynomial which captures polynomials with integer coefficients. Your class must provide at least the following features:
1-a method to create a polynomial by specifying a list of coefficients and a variable name as string, e.g., p=Polynomial([1,-2,3],"x") must create the polynomial 1-2x+3x2. If the coefficient list contains any value that is not an integer, a TypeError must be raised.
2-an implementation of the addition operator + to add polynomials that have the same variable.
3-conversion of a Polynomial into a string, which must return a representation of the form "1-2*x+3*x^2".
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
