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
Write a program to enter 30 integer numbers into an array and display​
Rama09 [41]

Answer:

i764

Explanation:

3 0
3 years ago
Read 2 more answers
What are the top and side margins for a letter typed in standard format?
ella [17]
They should be between 1 and 1/4 inches
8 0
3 years ago
Which statement is false? Select one: a. A class is to an object as a blueprint is to a house. b. Classes are reusable software
kow [346]

Answer:

A class is an instance of its object

Explanation:

6 0
3 years ago
Alison discovers that a system under her control has been infected with malware, which is using a key logger to report user keys
Bond [772]

Mostly the spyware and malware protection for desktop and laptop or workstations are to protected with anti-virus regular updates. All workstation or desktop or laptops are to updated operating systems patches.

If any operating systems patched update to be schedule and checked regularly. Schedule scanning by virus scanner to be made for desktop and laptop or workstations in regular interval basis

There are third parties tools such as malware and ADWCLEANER are also available free scanner software through internet where end user can download and scanner so software will clean the malware.

Mostly end user do mistake keep the files in desktop. Most of the malware software will affect the desktop folder only.

It will also affect c:\users folder and register enter keys.

7 0
3 years ago
Can anyone give me nitrotype gold? Name username is lol3628 display name is iluvkitkats
Vsevolod [243]

Answer:

no

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • While trying to solve a network issue, a technician made multiple changes to the current router configuration file. The changes
    7·1 answer
  • The steps for moving data from one cell to another are _____.
    14·1 answer
  • A marketing associate wants to use the Validate button to ensure an email is CAN-SPAM compliant. What information does the assoc
    5·2 answers
  • Information flows:
    11·1 answer
  • ____________ is demonstrated by the processes and procedures that an organization uses to meet the law.A. An auditB. SecurityC.
    15·2 answers
  • A technician has just installed a video card in a PC. The video card is not working, althoughit was working fine on the test ben
    6·1 answer
  • Match the item to the type.
    11·1 answer
  • What changes can be done using image editing tool?<br> a) Resize b) Crop c) Resize and crop
    6·1 answer
  • Usually it is a rectangular box placeed or underneath your desk​
    15·1 answer
  • Which of the following actions taken by the Fed will increase the nation’s money supply? (Select all that apply.)
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!