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 = 10 in the function to perform 10 iteratios.
- Calculate number = 0.5 * (number + a / number) for 10 iterations.
- Get input from user,define assumption value.
- Give function call.
/*
Program to find the square root for the given number(newton's method) using function.
Developed by: Sowmiya N
RegisterNumber: 21500134
*/
def root(x):
for i in range(10):
x=0.5*(x+b/x)
print("Square root of the number:",x)
x=int(input())
b=x
root(x)
Thus the program to find the square root for the given number(newton's method) using function is written and verified using python programming.