Click here to Skip to main content
15,891,722 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
cube=int(input(' enter a vlue to find it cube root,(vlue must be >1):'))
epsilon=0.01
num_guess=0
low=0
high=cube
guess=(high+low)/2.0
while abs(guess**3-cube)>=epsilon:
	if guess**3<cube:
			low=guess
	else:	#guess**3>=guess
		high=guess
		guess=(high+low)/2.0
		num_guess+1
		if(high==low):
			guess=low      #or it =high 
			break

print('number of guess=',num_guess)
print(guess)


What I have tried:

when i run it it give no respond it also cant give a arror...

example after run this program:

enter a vlue to find it cube root,(vlue must be >1):9




#its give nothing
Posted
Updated 27-Feb-18 21:35pm

With Python, indentation is the structure of your program, pay extra care to it.
Use the debugger and execute line by line, you will see what is wrong.

There is a tool that allow you to see what your code is doing, its name is debugger. It is also a great learning tool because it show you reality and you can see which expectation match reality.
When you don't understand what your code is doing or why it does what it does, the answer is debugger.
Use the debugger to see what your code is doing. Just set a breakpoint and see your code performing, the debugger allow you to execute lines 1 by 1 and to inspect variables as it execute.

Debugger - Wikipedia, the free encyclopedia[^]

Mastering Debugging in Visual Studio 2010 - A Beginner's Guide[^]
Basic Debugging with Visual Studio 2010 - YouTube[^]
27.3. pdb — The Python Debugger — Python 3.6.1 documentation[^]
Debugging in Python | Python Conquers The Universe[^]
pdb – Interactive Debugger - Python Module of the Week[^]
The debugger is here to show you what your code is doing and your task is to compare with what it should do.
There is no magic in the debugger, it don't find bugs, it just help you to. When the code don't do what is expected, you are close to a bug.
 
Share this answer
 
v2
Python
num_guess+1 # this is wrong, it does nothing

num_guess += 1  # this is correct, add 1 to num_guess
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900