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
What is the base for a hexadecimal number system?
miskamm [114]
The base for a hexadecimal number system is 16
5 0
3 years ago
1. Which of the following is not related to a buffer overflow? A. Static buffer overflow B. Index error C. Canonicalization erro
GaryK [48]

Answer: C) Canonicalization error

Explanation:

Canonicalization error is the error or fault that occurs when data is changed into canonical form or standard form that persist different representation.This can create fault when different filenames or structure is assigned to data and canonization cannot take place as it works for simple data representation.

  • Other options are incorrect because static buffer flow is stable writing or reading of data that reaches outside the buffer boundary.Index error is accessing of index by any user that is found beyond the index's list boundary.
  • Heap overflow is the stack gets overlowed outside the boundary while overwriting heap.Thus, the correct option is option(C).
4 0
3 years ago
How does Greenscreen work
Drupady [299]
<span>All of this high-tech fakery happens with the help of backdrops of brightly colored fabric or paint, and a process called "chroma key," also referred to as "green screen" due to the backdrops' color, which is typically a vivid green. ... Chroma keying isn't just for backgrounds; it works with objects, too.</span>
5 0
3 years ago
Read 2 more answers
Please answer this question​
Andrews [41]
Can you please upload it again
7 0
3 years ago
What is parallelism of microinstruction
Kitty [74]
The answer is Hardware level works upon dynamic parallelism whereas, the software level works on static parallelism. Dynamic parallelism means the processor decides at run time which instructions to execute in parallel,
8 0
3 years ago
Other questions:
  • Two electronics technicians are measuring electrical quantities in circuits. Technician A says that copper, glass, porcelain, an
    11·1 answer
  • Write an application that asks a user to type an even number or the sentinel value 999 to stop. When the user types an even numb
    8·2 answers
  • An Internet Service Provider (ISP) is a company that builds the routers and wired connections that allow individuals to access t
    12·2 answers
  • 3-Write a program in some language that has both static and stack dynamic local variables in subprograms. Create six large (at l
    9·2 answers
  • You install a teanviewer on your work station at home so that you can access it when on the road. How can you be assured that un
    12·1 answer
  • Is your florida learners license number the same as the actual license number?
    14·2 answers
  • Describe the process of normalization and why it is needed.
    12·1 answer
  • A mobile application delivers market predictions based on stock data from the stock market data platform. Knowing that the data
    12·1 answer
  • Write a program that asks the user to enter a positive integer that represents a number in the decimal system and then displays
    12·1 answer
  • Remember not to use tools that are ________ in any way.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!