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 03:30
Identify at least three types of characteristics that you were asked about as you the computer identify a fruit.
Answers: 3
question
Computers and Technology, 22.06.2019 17:50
Farah works in an office with two other employees. all three share a printer and an internet connection. the utility that makes this possible is defragger quicktime soho winzip
Answers: 1
question
Computers and Technology, 22.06.2019 19:00
The fourth generation of computers emerged between 1970s and 1980s. which technological advancement brought about this generation of computers? which computer architecture was used most in this generation?
Answers: 3
question
Computers and Technology, 23.06.2019 07:00
1. you have a small business that is divided into 3 departments: accounting, sales, and administration. these departments have the following number of devices (computers, printers, etc.): accounting-31, sales-28, and administration-13. using a class c private network, subnet the network so that each department will have their own subnet. you must show/explain how you arrived at your conclusion and also show the following: all available device addresses for each department, the broadcast address for each department, and the network address for each department. also, determine how many "wasted" (not usable) addresses resulted from your subnetting (enumerate them).
Answers: 3
You know the right answer?
Package Newton’s method for approximating square roots (Case Study: Approximating Square Roots) in a...
Questions
question
Mathematics, 20.01.2021 21:40
question
Mathematics, 20.01.2021 21:40
question
Mathematics, 20.01.2021 21:40
question
Arts, 20.01.2021 21:40
question
Mathematics, 20.01.2021 21:40
question
Mathematics, 20.01.2021 21:40
Questions on the website: 13722360