The following is pseudocode to compute the square root of an inputted number, called number.EPSILON = 1.0e-14answer = “yes”while answer[0] equals “Y” or answer[0] equals “y”prompt “Enter a number to be square rooted: “input numberapproximation = 1iteration = 0while absolute value of approximation * approximation minus numberis greater than EPSILONapproximation = 0.5 * (approximation + number / approximation)iteration++output “The square root of “ number “ is “ approximationoutput “The number of iterations needed were “ iterationprompt “Do you wish to continue?”input answerTranslate the above psuedecode into Python and use it to approximate various square roots.You program should produce the following output below. Be sure to include a docstringcomment in the beginning
Extracted text: >>> == RESTART : F:/CP1/Labs/Lab3/square_root.py This program calculates the square root of an inputted number and the number of iterations that the algorithm took to reach a degree of accuracy of le-14. Enter a nonnegative number: 24 The square root of 24.0 is 4.898979485566356. The number of iterations needed were 7. Do you wish to continue (y/n) ? y Enter a nonnegative number: 36 The square root of 36.0 is 6.0. The number of iterations needed were 7. Do you wish to continue (y/n) ? y Enter a nonnegative number: -3 Please enter a nonnegative number: 0 The square root of 0.0 is 5.960464477539063e-08. The number of iterations needed were 24. Do you wish to continue (y/n) ? y Enter a nonnegative number: 2 The square root of 2.0 is 1.414213562373095. The number of iterations needed were 5. Do you wish to continue (y/n) ? n >>>
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here