Question: Python Please Objective: poly Parameters: list of ints, int Returns: int Description: A polynomial of degree n with coefficients a0,a1,22,a3,...,an is the function p(x) =
Python Please

Objective: poly Parameters: list of ints, int Returns: int Description: A polynomial of degree n with coefficients a0,a1,22,a3,...,an is the function p(x) = (a0 * x) + (a1 * x') + (a2 * x2) + (a3 + x3) + ... + (an .x") This function can be evaluated at different values of x. For example: If p(x) = 1+2x + x2, then p(2) = 1+2 + 2+22 = 9. If p(x) = 1+x2+x4, then p(2) = 21 and p(3) = 91. Write a function polyo that takes as input a list of coefficients a, a1, a2, a3,..., an of a polynomial p(x) and a value x. The function will return poly(x), which is the value of the polynomial when evaluated at x. Sample Inputs/Outputs: Example Call: poly([1, 2, 1), 2) Expected Return: 9 Example Call: poly ([1, 0, 1, 0, 1], 2) Expected Return: 21 Example Call: poly ([1, 0, 1, 0, 1), 3) Expected Return: 91 296528.1655254.qx3zqy7 LAB ACTIVITY 13.57.1: Poly (Functions - Medium) 0/11 main.py Load default template... 1 #NOTE: Define the function requested. Do not create/use global variables. 2 3 4 5 ###DO NOT EDIT BELOW THIS LINE### 6 if __name__ - __main__': assert poly([1, 2, 1], 2) == 9 assert polyC[1, 0, 1, 0, 1], 2) == 21 9 assert poly([1, 0, 1, 0, 1], 3) == 91
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
