subject

Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a function named newton. This function expects the input number as an argument and returns the estimate of its square root. The program should also include a main function that allows the user to compute the square roots of inputs from the user and python's estimate of its square roots until the enter/return key is pressed. An example of the program input and output is shown below:
Enter a positive number or enter/return to quit: 2
The program's estimate is 1.4142135623746899
Python's estimate is 1.4142135623730951
Enter a positive number or enter/return to quit: 4
The program's estimate is 2.0000000929222947
Python's estimate is 2.0
Enter a positive number or enter/return to quit: 9
The program's estimate is 3.000000001396984
Python's estimate is 3.0
Enter a positive number or enter/return to quit

Modify the program below:
# Modify the code below
"""
File: newton. py
Project 6.1

Compute the square root of a number (uses function with loop).

1. The input is a number, or enter/return to halt the
input process.

2. The outputs are the program's estimate of the square root
using Newton's method of successive approximations, and
Python's own estimate using math. sqrt.
"""

import math

# Receive the input number from the user
x = float(input("Enter a positive number: "))

# Initialize the tolerance and estimate
tolerance = 0.000001
estimate = 1.0

# Perform the successive approximations
while True:
estimate = (estimate + x / estimate) / 2
difference = abs(x - estimate ** 2)
if difference <= tolerance:
break

# Output the result
print("The program's estimate is", estimate)
print("Python's estimate is", math. sqrt(x))

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 10:30
What can tanya do now to start preparing for the college and scholarship application process? think about her grades, activities in which she can get involved, possible part-time jobs at which she can work, and standardized tests she can take. (10 points) apex
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
Under which key category do the page up and page down keys fall? page up and page down keys fall under the keys category.
Answers: 1
question
Computers and Technology, 23.06.2019 00:30
Which of the following would you find on a network
Answers: 3
question
Computers and Technology, 23.06.2019 06:30
On early television stations, what typically filled the screen from around 11pm until 6am? test dummies test patterns tests testing colors
Answers: 1
You know the right answer?
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a...
Questions
question
Biology, 03.12.2020 01:30
question
History, 03.12.2020 01:30
question
Mathematics, 03.12.2020 01:30
question
Mathematics, 03.12.2020 01:30
question
Mathematics, 03.12.2020 01:30