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 19:20
Terri needs to insert a cover page into her document. where should she go to access the commands to do so? o insert tab, objects group o insert tab, illustrations group o insert tab, pages group o insert tab, media group submit
Answers: 1
question
Computers and Technology, 22.06.2019 20:00
Awide variety of “ apps “ are available to customize devices. which category of app does the word processing software fall into?
Answers: 2
question
Computers and Technology, 23.06.2019 09:30
Name the range function that would generate the following list of integers values: 0,1,2,3,4,5.
Answers: 1
question
Computers and Technology, 23.06.2019 12:00
Which of these is an example of an integrated presentation? a. a table created in powerpoint b. an image pasted into powerpoint c. a caption created in powerpoint d. an excel chart pasted into powerpoint
Answers: 1
You know the right answer?
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a...
Questions
question
English, 25.11.2021 16:10
question
Chemistry, 25.11.2021 16:10
question
English, 25.11.2021 16:10
question
Mathematics, 25.11.2021 16:20
question
Mathematics, 25.11.2021 16:20
Questions on the website: 13722360