I have a task to calculate a square root using the Newton method using a function within a function. The user enters a number that he wants to know his root and another number that is his guess to the root. The program I made works but the problem is that it only works for integer numbers. Although I convert the input to float when I set for example the number 2 and for example a guess 1 it gives me only the integer and not the decimal i mean instead of 1.4142 it gives 1. I would love to understand where the problem is. Thanks in advance !
my code :
def mySqrt2():
number=float(input('enter a number that you want to find its root:'))
n=float(input('enter your Guess:'))
def mySqrt1(number,n):
def checkIfGood():
def ImprovingGuess():
newguess=n
i=0
while i!=100:
temp=number//newguess
newguess=(temp+newguess)//2.0
i+=1
return newguess
if n == (number**.5):
return 'your guess is good!'
else:
return ImprovingGuess()
return checkIfGood()
return mySqrt1(number,n)
print('The result is :',mySqrt2())