x = -37
epsilon = 0.01
num_guess = 0
low = 0.0
high = abs(x)
ans = ((low + high)/2.0)
while abs(ans**3-abs(x)) >= epsilon:
#print("low = " + str(low) + " high " + str(high) + " ans = " + str(ans))
if ans**3 < abs(x):
low = ans
else :
high = ans
ans = ((low + high)/2.0)
num_guess += 1
if x < 0:
ans = -ans
print("Steps taken during bisecction search: ",num_guess)
print("The cube root of " + str(x) + " is " + str(ans))
this is the code sample. I couldn't find a way to find the cube root of floats. Dont know where to insert the command and somehow the site needs more details , so this is why I am writing so much