我是新來編程和使用pydev來在Eclipse中運行我的python。我使用Eclipse EE和Python 2.7.3,我嘗試運行的代碼是在這裏:爲什麼每次我嘗試運行我的Python程序時,Eclipse都會要求我「構建」?
def evaluate_poly(poly, x):
sumPoly = 0
for i in range(0,len(poly)):
#calculate each term and add to sum.
sumPoly = sumPoly+(poly[i]*x**i)
return sumPoly
def compute_deriv(poly):
derivTerm =()
#create a new tuple by adding a new term each iteration, assign to derivTerm each time.
for i in range(0,len(poly)):
#i is the exponent, poly[i] is the coefficient,
#coefficient of the derivative is the product of the two.
derivTerm = derivTerm + (poly[i]*i,)
return derivTerm
def compute_root(poly, x_0, epsilon):
#define root to make code simpler.
root = evaluate_poly(poly,x_0)
iterations = 0
#until root (evaluate_poly) is within our error range of 0...
while (root > epsilon) or (root < -epsilon):
#...apply newton's method, calculate new root, and count iterations.
x_0 = (x_0 - ((root)/(evaluate_poly(compute_deriv(poly),x_0))))
root = evaluate_poly(poly,x_0)
iterations = iterations + 1
return (x_0,iterations)
print compute_root((4.0,3.0,2.0),0.1,0.0001)
每次我嘗試運行月食問我ant構建。當我點擊確定沒有任何反應。這隻發生在我在函數內部運行函數時,它看起來很基本,代碼不是問題。出了什麼問題,我該如何解決這個問題?
這是Eclipse的一般煩惱,不需要顯示代碼,也不會導致問題。 – smci