-1
我正在学习python,但是这段代码不断崩溃我的文本编辑器。Sublime2不断崩溃?我的Python代码有什么问题?
谁能告诉我我做错了什么?
x = 12
epsilon = 0.01
numGuesses = 0
low = 0.0
high = max(1.0, x)
ans = (high + low)/2.0
while abs (ans**2 - x) >= epsilon:
print 'low =', low, 'high =', high, 'ans =', ans
numGuesses += 1
if ans**2 < x:
low = ans
else:
high - ans
ans = (high + low)/2.0
print 'numGuesses =', numGuesses
print ans, 'is close to square root of', x
有什么建议吗?
高= ans而不是高-ans – lakesh 2014-10-26 19:27:20
这段代码肯定与编辑器崩溃无关。如果是这样,这将是脱离主题,并将属于superuser.com – 2014-10-26 19:29:45