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
Question 4 (2 points)
Kay [80]

Answer:

Syntax

Explanation:

Syntax errors include misspelled words or missing code.

Logic errors cause the program to operate incorrectly,

Runtime errors occur while running a computer program.

7 0
2 years ago
Exampels of semantic tags ?​
spayn [35]
A semantic element clearly describes its meaning to both the browser and the developer.Examples of non-semantic elements: and <span> - Tells nothing about its content. Examples of semantic elements: ,, and - Clearly defines its content.</span>
4 0
3 years ago
Pros and cons of the inter's<br> ability to access information
SpyIntel [72]
Pros and cons of the internet are the pros you can get the informaqtion needed to research and find out any information at your finger tips and get the answerws you need to certqin things fast. The cons the main one ise the people who misuse this to st4eal your information and indenity.
7 0
3 years ago
While working on a presentation, Jack lost all the data because he switched off his computer unknowingly. On which of these comp
Lelechka [254]

Random Access memory(RAM) stores data temporary until the computer is switched off

3 0
3 years ago
Read 2 more answers
Q1. Which implementation of Network Access Control checks users' credentials to determine what level of access they should have
sesenic [268]

Answer:

3. RBAC

Explanation:

6 0
3 years ago
Other questions:
  • The Apple II is an IBM-compatible PC "clone.
    8·1 answer
  • The disk drive is a secondary storage device that stores data by ________ encoding it onto circular disks.
    11·1 answer
  • 1.
    7·1 answer
  • Which of the following is the definition of Internet Protocol Security ( IPSec)? A remote access client/server protocol. It is a
    13·2 answers
  • Why are user application configuration files saved in the user’s home directory and not under /etc with all the other system-wid
    6·1 answer
  • What does CRM stand for?
    10·1 answer
  • Programmers refer to programs that contain meaningful names as ____. AnswerThe answer is: Programmers refer to programs that con
    12·1 answer
  • With a DUI charge on a driver’s record A. the price of his/her insurance greatly increases. B. he/she may drive only during day
    5·2 answers
  • Which is an example of a demand account
    10·1 answer
  • Which type of data storage allows computers to read and write to the memory while the computer is powered on?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!