This program will calculate the square root of possible number. And this will give the approximate value as calculator.
Newton’s method square root code:
inputStr = input (‘Input a number: ‘)
number= int(inputStr)
if number<0:
print (‘You entered the negative number!’)
else:
guess=number/2
count=0
while count<20:
tempt=float(number/guess)
guess=(guess+tempt)/2
count=count+1
print(“square root %.2f” % guess)