cube = 8120601
epsilon = 0.01
guess = 0.0
increment = 0.0001
num_guesses = 0
# while abs(guess ** 3 - cube) >= epsilon and guess < cube:
while cube - guess**3 >= epsilon:
guess += increment
num_guesses += 1
print('Guesses %d times.' % num_guesses)
print(guess,"is close to the cube root of", cube)
网友评论