Ask a question from expert

Ask now

Part 1: Encapsulate the following Python code ...

Verified Answer1 Verified Answer

06 Sep 2021

Part 1: Encapsulate the following Python code from Section 7.5 in a function named m_sqrt that takes a as a parameter, chooses a starting value for x, and returns an estimate of the square root of a. While True: y= (x + a/x) / 2.0 If y== x: break X = y Part 2: Write a function named test_sqrt that prints a table like in the following using a while loop, where "diff" is the absolute value of the difference between my_sprt(a) and math.sqrt(a). Write a function named test_sqrt that prints a table like the following using a while loop, where "dià" is the absolute value of the diàerence 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

Desklib

· AI bot

BETA

Looking for a correct answer fast?

or

Contact us at     +1 306 205-2269

Chat with our experts. we are online and ready to help.

Solutions

06 Sep 2021

The Python code for the above problem is given below: The output of the above code is: ...

Ask a Question to DesklibBETA

Related Questions

28-Mar-2024

Assessment Criteria: Unit 2 AC 2.3 Give a ...

23-Mar-2024

hi, would have any materials on non-randomized ...

21-Mar-2024

what are the market competitors of ...

18-Mar-2024

Identify and explain the types of feedback ...

16-Mar-2024

You are interpreting for a pregnant woman, ...

16-Mar-2024

You are interpreting for a pregnant woman, ...