1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Olegator [25]
3 years ago
7

Package Newton’s method for approximating square roots (Case Study 3.6) in a function named newton. This function expects the in

put number as an argument and returns the estimate of its square root. The script should also include a main function that allows the user to compute square roots of inputs until she presses the enter/return key.
Computers and Technology
1 answer:
notka56 [123]3 years ago
8 0

Answer:

import math

#Initialize tolerance

tolerance = 0.000001

def newton(x):

   """ Returns the square root of x """

   #Performs the successive approximations

   estimate = 1.0

   while True:

       estimate = (estimate + x / estimate) / 2

       difference = abs(x - estimate ** 2)

       if difference <= tolerance:     # Break out of loop if difference is less than tolerance

           break            

       return estimate     # While the difference value is > TOLERANCE, the process continues

def main():

   """Allows the user to obtain square roots."""

   while True:

       #Receive the input number from the user

       x = input("Enter a positive number or enter/return to quit: ")

       if x == "":     #if user presses "Enter" then exit the program

           break       # Otherwise, continue the process of allowing new numbers

       x = float(x)

       #Output the result

       print("The programs estimate of the square root of ", x, "is ", round(newton(x),2))

       print("Python's estimate: ", math.sqrt(x))

main()

You might be interested in
_____ are fields that are used to personalize a mail merge document
Rzqust [24]

Answer:

The answer is A; rows of a spreadsheet data source.

Explanation:

8 0
2 years ago
You can add envelopes to existing documents. <br> a. True <br> b. False
Lemur [1.5K]
<span>The answer is true. Once documents are created, they may be accessed again and have envelopes pointing to them even when the documents are empty.</span>
3 0
2 years ago
What are the disadvantages of vector images when compared to bitmap images?
Lana71 [14]
I don’t understand what you mean
7 0
2 years ago
A computer that no longer works after having minor repair works done to it may have been damaged by
FinnZ [79.3K]
Shipping or misrepair.
3 0
3 years ago
Read 2 more answers
Which symbol is at the beginning and end of a multiline comment block? &amp;&amp;&amp; """ %%% ###
yawa3891 [41]

Answer:

#

Explanation:

I have notes on it we learned it in 8th

7 0
3 years ago
Other questions:
  • Smart art can be used to create _____that highlights relationships betweeen two items
    8·2 answers
  • Why is it important to respect other political opinions
    7·2 answers
  • Some classes, like the ArrayList class, use angle brackets in their documentation and their declaration. For example, the Java d
    5·1 answer
  • Lexi wants to buy a $300 painting. when she gets to the store, she finds that it is on sale for 40% off. how much does Lexi spen
    10·1 answer
  • Match each proofreading mark to the expected result.
    10·1 answer
  • Is it good to work out at the gym one day with hands then the next with feet, then a pattern?
    11·2 answers
  • Which of the following is the file type of Microsoft® Publisher files?
    12·2 answers
  • Samantha is part of a project management team working on the initiation phase of a project. What is her team expected to do in t
    5·2 answers
  • I WILL MARK BRAINIEST FOR THIS!!!!!!
    11·2 answers
  • PLEASE HELP ME
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!