我想在python中使用函数f(x).像ax ^ 2 + bx + c(多项式)之类的东西.我想使用for循环和列表来做到这一点.这是我到目前为止:
def f(a,x):
for i in range (0, len(a)):
i = ([a]*x**i)
print (i)
Run Code Online (Sandbox Code Playgroud)
例如:当我填写时,f([5,2,3],5)我必须得到:3*5 ^ 0 + 2*5 ^ 1 + 5*5 ^ 2.有人知道如何更改我的代码,因此输出将是该多项式的结果吗?
python ×1