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
Let PALINDROME_DFA= | M is a DFA, and for all s ∈ L(M), s is a palindrome}. Show that PALINDROME_DFA ∈ P by providing an algorit
denis-greek [22]

Answer:

Which sentence best matches the context of the word reticent as it is used in the following example?

We could talk about anything for hours. However, the moment I brought up dating, he was extremely reticent about his personal life.

Explanation:

Which sentence best matches the context of the word reticent as it is used in the following example?

We could talk about anything for hours. However, the moment I brought up dating, he was extremely reticent about his personal life.

8 0
2 years ago
How do I mark someone brainiest
svet-max [94.6K]

Answer:

when someone answers your questio correctly, you will see a red crown. Click on that and mark them the most brainiest

Explanation:

3 0
2 years ago
Read 2 more answers
Please help...........​
MrMuchimi

Answer:

Explanation:

As a user of GPL v3 software, you have lots of freedom: You can use GPL software for commercial purposes. You can modify the software and create derivative work. You can distribute the software and any derivative work you produce, without having to ask for permission or pay

4 0
2 years ago
Read 2 more answers
calculate how many turns of cable you will need on the drum for your cage and skip to move up and down by 500 m​
anyanavicka [17]
Physics. only one, if the drum is 500m around... 50 turns. you will need on the drum for your cage and skip to move up and down by 500m. 500/18.84= 26.5.

Mark me as brainliest pls..... :)
5 0
2 years ago
Q1: Which of the following is an input peripheral device?
faltersainse [42]

Answer:

Mouse

Explanation:

Input devices allow users to input something in the computer. For example keyboard allows users to type on the computer, or mouse allows users to click.

On the other hand output devices allow computers to output data. For example speakers allow us to hear the outputs of a computer.

3 0
3 years ago
Read 2 more answers
Other questions:
  • How technology bacome the mode of revealing​
    10·1 answer
  • Which command is used to combine two or more cells together into one cell?
    14·2 answers
  • ? Assessment
    12·1 answer
  • The Cursor is blinking in a white area on the Screen. This area where text will appear in the ____.
    10·2 answers
  • What is the empty space inside the character 'O' called?
    12·1 answer
  • it is used to hold screws, jumpers, fasteners, and other small parts and prevent them from getting mixed together​
    15·2 answers
  • Choose the appropriate computing generation.
    7·2 answers
  • ASAP BRAINLIEST!!!
    10·1 answer
  • write an assembly program that uses the output compare function of a timer to toggle an led every second
    6·1 answer
  • // This pseudocode is intended to describe
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!