我试图编写一个计算任意数字的立方根的代码
cube = int(input("Please Enter the number : "))
root = 0.0
tries = 0
add = 1
positive = True
while root ** 3 < cube or root ** 3 > cube :
if root ** 3 < cube :
if positive == True :
root += add
tries += 1
elif positive == False :
positive = True
add = add/10
tries += 1
elif root ** 3 > cube :
if positive == True :
positive = False
add = add/10
tries += 1
elif positive == False :
root -= add
tries += 1
print("The root is " + str(root) + ", Tries : " + str(tries))
当我转到http://www.pythontutor.com/live.html并尝试调试代码时,我看到如果我将值11分配给&#39; cube&#39;例如,(在步骤227中)当我决定添加&#39; (即0.0001)由10变为0.为什么?? !!