easy +5 pts

Polynomial evaluator

Evaluate a polynomial at a given x using Horner's method.

Write a function `evaluate_polynomial(coeffs, x)` that returns the value of the polynomial whose coefficients are given in `coeffs`. The coefficients are ordered from the highest degree to the constant term. For example, `coeffs = [3, -2, 5]` represents the polynomial `3*x**2 - 2*x + 5`. Evaluate the polynomial for the given value `x`. The result should be an integer or float as appropriate. Implement the function using Horner's method for efficiency, but any correct evaluation is accepted. **Signature:** ```python def evaluate_polynomial(coeffs: list, x: float) -> float: ```

Constraints

- `coeffs` is a list of integers or floats; its length is between 1 and 1000. - `x` is an integer or float. - The final result may be large; Python integers can handle arbitrary size.

Example

```python
>>> evaluate_polynomial([2, 3], 5)
13
>>> evaluate_polynomial([1, 0, -4], 2)
0
>>> evaluate_polynomial([1, 0, 0], -3)
9
>>> evaluate_polynomial([0, 0, 0], 100)
0
```
5 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Start with the highest-degree coefficient and repeatedly multiply by x and add the next coefficient.
If you start from the constant term, you might need to build the result as a sum of terms.
Horner's method processes coefficients from left to right.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.