Programming Assign. Unit 5 Part 1 Encapsulate the following Python code from Section 7.5 in a function named my_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 the following using a while loop, where "diff" is the absolute value of 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)? Part 1 Encapsulate the following Python code from Section 7.5 in a function named my_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 the following using a while loop, where "diff" is the absolute value of 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)?

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
100%
Programming Assign. Unit 5 Part 1 Encapsulate the following Python code from Section 7.5 in a function named my_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 the following using a while loop, where "diff" is the absolute value of 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)? Part 1 Encapsulate the following Python code from Section 7.5 in a function named my_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 the following using a while loop, where "diff" is the absolute value of 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)?
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Datatypes
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education