Evaluate Polynomial
Background
Horner's method is an efficient algorithm for evaluating polynomials. It reduces the number of multiplications needed, transforming a polynomial of degree $n$ into a nested form.
Task
Write a function poly_evaluate(poly, x) that evaluates a polynomial at a given value $x$. The polynomial is represented by a list of its coefficients, from the highest degree term to the constant term.
Specifications
- The function takes a list of coefficients
polyand a valuex. - It should return the evaluated polynomial as a number.
- Must implement Horner's method efficiently.
Constraints
- The list
polywill have at least one element. - All elements in
polyandxwill be numbers.
Example
Instructions
- Implement the logic in
solution.py. - Do not use
input()orprint(). - Test your solution locally before submitting.