Articles

# Python program to find square root of a number by newton's method

🤷‍♂️Hello learners, Welcome back to yet another article on Python. In this article, we are going to learn:

• python program to find square root of a number by newton's method

So let’s get started:

### 🤷‍♂️🤷‍♂️What is the Newton Square Root formula?

If a given number is N, then its square root can be given by the below formula:

🔓square_root = 0.5 * (Q + (N / Q)) where Q is any guess which can be assumed to be N or 1.

In the given formula We take Q as an assumed square root of N and square_root is the correct square root of N.

### 💻Program For finding Square root using Newton's Method:

Given below is python program to find square root of a number by newton's method:

``````def newtonSqrt(n, base):
approx_root = 0.5 * n
for i in range(base):
betterapprox = 0.5 * (approx_root + n/approx_root)
approx_root = betterapprox
return betterapprox

``````
`print("the square root of 100 :",newtonSqrt(100, 10))`
`print("the square root of 256 :",newtonSqrt(256, 10))`
`print("the square root of 24 :",newtonSqrt(24, 10))`
``````Output

the square root of 100 : 10.0
the square root of 256 : 16.0
the square root of 24 : 4.898979485566356``````

🧐In this Program base is the base of number we are going to find whether it is binary,decimal or hexadecimal.

🔓🔓👌That's all in this article - square root of a number by newton's method in python.

Basic Python Programs
Python Numbers Program

Would you like to see your article here on tutorialsinhand. Join Write4Us program by tutorialsinhand.com 