P87 Write Python Program Store Polynomial 5 10 9 7 10p X 5×10 9×7 X 10 List Terms Term Con Q43828837
(Same as P8.7) Write a Python program that canstore a polynomial such as
( )=5 10+9 7– –10p(x)=5×10+9×7–x–10
as a list of terms. A term contains the coefficient andthe power of x. For example, you would store the above ( )p(x)as
[(5, 10), (9, 7), (–1, 1), (–10, 0)]
-
Write functions to add_, _multiply_, _evaluate_, and_print polynomials.
-
Write a function that makes a polynomial from a single term. Forexample, the polynomial p can be constructed as
p = new_polynomial( -10, 0 ) add_term( p, -1, 1 ) add_term( p, 9, 7 ) add_term( p, 5, 10 )
-
Then compute ( )× ( )p(x)×p(x).
q = multiply( p, p ) print_polynomial( q )
-
Finally, evaluate a polynomial, given the variable (say, x)value:
v = evaulate( p, 1 )
should return 3[ ( =1)=5(1)10+9(1)7–1–10=5+9−1−10=3][p(x=1)=5(1)10+9(1)7–1–10=5+9−1−10=3].
In [ ]:
(Same as P8.8) Repeat Question3 but use a dictionary for the coefficients.
Expert Answer
Answer to (Same as P8.7) Write a Python program that can store a polynomial such as ( )=5 10+9 7– –10p(x)=5×10…
OR