小编Pau*_*aul的帖子

在python中使用正常函数f(x)

我想在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

5
推荐指数
1
解决办法
84
查看次数

标签 统计

python ×1