To write a program to find the square root of a number.
- Hardware โ PCs
- Anaconda โ Python 3.7 Installation / Moodle-Code Runner
- Define a function.
- Assign number_iters = 100 in the function to perform 100 iteratios.
- Set i = 0.
- Calculate number = 0.5 * (number + a / number) for 100 iterations.
- Return number
def sqroot():
num1=int(input())
num2=float(num1)
for i in range(100):
num1=0.5*(num1+num2/num1)
print("Square root of the number:",num1)
sqroot()
/*
Program to find the square root for the given number(newton's method) using function.
Developed by: RIYA P L
RegisterNumber: 23005672
*/
Thus the program to find the square root for the given number(newton's method) using function is written and verified using python programming.