I'm a novice in Python. As part of an exercise, I tried to compute the square root of a number using Newton Raphson's method.
It compiled perfectly, but failed to run.(Blank Screen in the Terminal)
Here's the code -
- Code: Select all
number = 24 #Number to be computed - I avoided raw_input() thinking that might be the cause.
epsilon = 0.01 # Least error tolerable in the computation of the square root.
guess = number/2
while abs(guess*guess - number) >= echleon:
guess = guess - (((guess**2) - number)/(2*guess))
print guess, 'is close to the answer'