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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started