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
KatRina [158]
3 years ago
4

Write a function named test_sqrt that prints a table like the following using a while loop, where "diff" is the absolute value o

f the difference between my_sqrt(a) and math.sqrt(a). a = 1 | my_sqrt(a) = 1 | math.sqrt(a) = 1.0 | diff = 0.0 a = 2 | my_sqrt(a) = 1.41421356237 | math.sqrt(a) = 1.41421356237 | diff = 2.22044604925e-16 a = 3 | my_sqrt(a) = 1.73205080757 | math.sqrt(a) = 1.73205080757 | diff = 0.0 a = 4 | my_sqrt(a) = 2.0 | math.sqrt(a) = 2.0 | diff = 0.0 a = 5 | my_sqrt(a) = 2.2360679775 | math.sqrt(a) = 2.2360679775 | diff = 0.0 a = 6 | my_sqrt(a) = 2.44948974278 | math.sqrt(a) = 2.44948974278 | diff = 0.0 a = 7 | my_sqrt(a) = 2.64575131106 | math.sqrt(a) = 2.64575131106 | diff = 0.0 a = 8 | my_sqrt(a) = 2.82842712475 | math.sqrt(a) = 2.82842712475 | diff = 4.4408920985e-16 a = 9 | my_sqrt(a) = 3.0 | math.sqrt(a) = 3.0 | diff = 0.0 Modify your program so that it outputs lines for a values from 1 to 25 instead of just 1 to 9. You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted. Your submission will be assessed using the following Aspects. Does the submission include a my_sqrt function that takes a single argument and includes the while loop from the instructions? Does the my_sqrt function initialize x and return its final value? Does the test_sqrt function print a values from 1 to 25? Does the test_sqrt function print the values returned by my_sqrt for each value of a? Does the test_sqrt function print correct values from math.sqrt for each value of a? Does the test_sqrt function print the absolute value of the differences between my_sqrt and math.sqrt for each value of a? Does the my_sqrt function compute values that are almost identical to math.sqrt ("diff" less than 1e-14)?

Computers and Technology
1 answer:
djverab [1.8K]3 years ago
8 0

Answer:

See explaination

Explanation:

import math

# Receive the input number from the user

def my_sqrt(x):

# Initialize the tolerance and estimate

tolerance = 0.000001

estimate = 1.0

# Perform the successive approximations

while True:

estimate = (estimate + float(x) / estimate) / 2

difference = abs(float(x) - estimate ** 2)

if difference <= tolerance:

break

diff = abs(math.sqrt(float(x))-estimate)

# Output the result

print("a = ",x," | my_sqrt(a) = ",estimate," | math.sqrt(a) = ",math.sqrt(float(x))," | diff = ",diff)

#print("The program's estimate is", estimate)

#print("Python's estimate is ", math.sqrt(float(x)))

x = 1

while(x<=25):

my_sqrt(x)

x+=1

Check attachment for output and screenshot

You might be interested in
A new company has proposed a number of different cache layouts for their system and you’ve
jonny [76]

Answer:

66 bytes, 50 bytes and 27 bytes

Explanation:

Cache can be defined as an area or type of computer memory in which information that is often in use can be stored temporarily and got to especially quickly.

It's a hardware or software that is used to store something, usually data, temporarily in a computing environment.

See attachment for a step by step solution to the questions.

4 0
3 years ago
What is the task included in the information systems manager?​
kobusy [5.1K]

Answer:

research and install new systems and networks. implement technology, directing the work of systems and business analysts, developers, support specialists and other computer-related workers. evaluate user needs and system functionality, ensuring that IT facilities meet these needs.

Explanation:

5 0
3 years ago
Conceptual note-taking is the act of writing down information in the order it is given. drawing attention to details with a mark
Dvinal [7]

Answer:A

Explanation:Conceptual notetaking is the act of writing down information in the order it is given.

4 0
3 years ago
Read 2 more answers
Spelling and grammar checking options can be controlled at the word options dialog box. To display this dialog box, begin by cli
Cerrena [4.2K]
By clicking the file tab
8 0
4 years ago
Advanced Sounds is engaging in a full upgrade of its Windows Server 2003 network to Windows Server 2008. The upgrade includes us
Lynna [10]

Answer:

cs

Explanation:

5 0
3 years ago
Other questions:
  • What is a sluggish beta signal detection theory?
    15·1 answer
  • Create a class called Name that will have three fields first name, middle initial, and last name as parameters. Add a constructo
    15·1 answer
  • Ou have an application running on Oracle Cloud Infrastructure. You identified that the read and write operations are slowing you
    10·1 answer
  • Mark of athena ar answers
    6·1 answer
  • Kelvin owns a small trading firm. Recently, he suspected that some of his employees were using fraudulent activities for their p
    5·2 answers
  • What do astronomers call a system that is composed of more than two stars?
    9·2 answers
  • Why does atmospheric pressure does not effect on planes,jet planes and rocket?​
    9·1 answer
  • Design a base class, Road, with the following members:
    13·1 answer
  • Ví dụ sau sẽ in ra dữ liệu của x là kiểu gì ?
    9·1 answer
  • Does technology always follow the science,yes or no explain why to choice
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!