FIFA-2022 Career Guide Free Tutorials Go to Your University Placement Preparation 
0 like 0 dislike
43.9k views
in RGPV/UTMP B.Tech (CSE-V Sem) Python Lab by Goeduhub's Expert (5.8k points)

Python Program to find the square root of a number by Newton’s Method

1 Answer

0 like 0 dislike
by Goeduhub's Expert (5.8k points)
edited by
 
Best answer

Newton's Method to find Square root

Let the given number be b and let x be a rough guess of the square root of b. 

New x = 0.5 * (x + b/x)

Program Code

def newton_method(number, number_iters = 100):

    a = float(number) 

    for i in range(number_iters): 

        number = 0.5 * (number + a / number) 

    return number

a=int(input("Enter first number:"))

b=int(input("Enter second number:"))

print("Square root of first number:",newton_method(a))

print("Square root of second number:",newton_method(b))

Output

Enter first number:81
Enter second number:5
Square root of first number: 9.0
Square root of second number: 2.23606797749979

For more RGPV/UTMP CSE V Sem Python Lab Experiments Click here


Learn & Improve In-Demand Data Skills Online in this Summer With  These High Quality Courses[Recommended by GOEDUHUB]:-

Best Data Science Online Courses[Lists] on:-

Claim your 10 Days FREE Trial for Pluralsight.

Best Data Science Courses on Datacamp
Best Data Science Courses on Coursera
Best Data Science Courses on Udemy
Best Data Science Courses on Pluralsight
Best Data Science Courses & Microdegrees on Udacity
Best Artificial Intelligence[AI] Courses on Coursera
Best Machine Learning[ML] Courses on Coursera
Best Python Programming Courses on Coursera
Best Artificial Intelligence[AI] Courses on Udemy
Best Python Programming Courses on Udemy

Related questions

 Important Lists:

Important Lists, Exams & Cutoffs Exams after Graduation PSUs

 Goeduhub:

About Us | Contact Us || Terms & Conditions | Privacy Policy ||  Youtube Channel || Telegram Channel © goeduhub.com Social::   |  | 

 

Free Online Directory

...