我写这段代码
def evaluate_poly(poly, x):
"""
Computes the value of a polynomial function at given value x. Returns that
value as a float.
Example:
>>> poly = [0.0, 0.0, 5.0, 9.3, 7.0] # f(x) = 5x^2 + 9.3x^3 + 7x^4
>>> x = -13
>>> print evaluate_poly(poly, x) # f(-13) = 5(-13)^2 + 9.3(-13)^3 + 7(-13)^4
180339.9
poly: list of numbers, length > 0
x: number
returns: float
"""
# FILL IN YOUR CODE HERE ...
answer = 0.0
for i in range(0, len(poly)):
answer +=poly[i]*(x**i)
return float(answer)
并始终如一地得到回应
Traceback (most recent call last):
File "<pyshell#53>", line 1, in <module>
evaluate_poly( [0.0, 0.0, 5.0, 9.3, 7.0], -13)
File "/Users/katharinaross/Downloads/ps2/ps2_bisection.py", line 28, in evaluate_poly
answer +=poly[i]*(x**i)
TypeError: 'list' object is not callable
所有的“””都是我的教授关于代码应该如何运行的例子的注释。这是什么意思?