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
Consider that a large online company that provides a widely used search engine, social network, and/or news service is consideri
k0ka [10]

Answer:

I think that they should ban ads for all four products.  These products, e-cigarettes, abortion clinics, ice cream, and sugared soft drinks, are all discreet adult products that should not be advertised because of their health hazards.  Since the "large online company provides a widely used search engine, social network, and/or news service, which are mainly patronized by younger people, such ads that promote products injurious to individual health should be banned.  Those who really need or want these products know where they could get them.  Therefore, the products should not be made easily accessible to all people.  Nor, should ads promote their patronage among the general population.

Explanation:

Advertisements create lasting and powerful images which glamourize some products, thereby causing the general population, especially children, to want to consume them without any discrimination of their health implications.  If online banning is then contemplated, there should not be any distinguishing among the four products: e-cigarettes, abortion clinics, ice cream, and sugared soft drinks.

7 0
3 years ago
Update thejavafile names to include your initials at the end, send .java file only.1. Completein-place heapSort, which takes an
Sladkaya [172]

Answer:

Yes

Explanation:

Because you send it to the java file and the java file is only one single (1)

3 0
3 years ago
What aspects of your life are most influenced by media and technology​
Anastasy [175]

Answer:

Everyday life

Explanation:

Television

office work (computers )

Music

video games

ware house work uses technology

work from home jobs use technology

cellular towers

5 0
3 years ago
Which slide elements must claire use to enhance her presentation?
Crank

The answer for the 1st blank is text.


6 0
3 years ago
Read 2 more answers
If you would like to compare information on two different Web pages, you should _____.
Gekata [30.6K]

Answer:

Use Tabs

Explanation:

I had this lesson on odyessy ware and this was right the other guy is wrong

4 0
2 years ago
Read 2 more answers
Other questions:
  • The layout button is located in the ____ group on the home tab?
    14·1 answer
  • What can be done to improve the security of business uses of the Internet? Give several examples of ecurity measures and technol
    9·1 answer
  • Which of the following actions is an example of "window dressing?" a. Using some of the firm’s cash to reduce long-term debt. b.
    13·1 answer
  • Robert's employer has agreed to pay half the tuition for Robert to complete his college degree. This benefit is known as what?
    7·2 answers
  • If you do not use the mini toolbar, it remains on the screen. _______________​ Group of answer choices True False
    8·1 answer
  • HELP PLS
    5·2 answers
  • A ____ is a a set of presentation rules that control how text should look. It is applied to an XML file to change the collection
    9·1 answer
  • processing C. have only one function, e.g. control traffic lights in a town, games machines 7 To create a formula, you first: A.
    13·1 answer
  • 2. How can Tailwind Traders ensure applications use geo-redundancy to create highly available storage applications?
    10·1 answer
  • If userNum1 is less than 0, put "userNum1 is negative.\n" to output. If userNum2 is greater than 10, assign userNum2 with 0. Els
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!