2013-09-29 48 views
0
import math 


def main(): 
    loop=eval(input("How many times do you want to run the loop?")) 
    x=eval(input("What number are you taking the square root of? ")) 
    for i in range(loop): 
     x=guess 
     x/2=(guess+(x/guess))/2 
    print(guess) 

main() 
+0

'x/2 =(guess +(x/guess))/ 2' - 這條線應該做什麼? – raina77ow

+0

這是一個數學公式,它使用牛頓法,找到平方根 – user2829162

+1

我並不是在問一般的目的。我在問這條線與Python語法有什麼關係。 – raina77ow

回答

1

行之後引起語法錯誤:

x/2=(guess+(x/guess))/2 

也許錯字以下的?

x = (guess+(x/guess))/2