【发布时间】:2014-08-13 04:06:02
【问题描述】:
我正在尝试编写一个简单的程序来计算多项式函数的导数。这就是我所拥有的。它可能不漂亮,但由于某种原因,for 循环不可迭代(不管这意味着什么)。
def main():
n = int(input("please enter the degree of the polynomial: "))
x = int(input("please enter the input for p(x): "))
p = 2*x**n + 3*x**(n-1)
v = int(input("please enter the order of the derivative: "))
for i in v:
p = 2*n*x**(n - i) + 3*(n-1)*x**((n - 1) - i)
print p
main()
【问题讨论】:
-
不要含糊地描述问题,而是发布实际的异常,并带有回溯。或者,如果您没有遇到异常,请准确告诉我们发生了什么,以及它与您的预期有何不同。
标签: python calculus derivative