he following is pseudocode to compute the square root of an inputted number, called number. EPSILON = 1.0e-14 answer = “yes” while answer[0] equals “Y” or answer[0] equals “y” prompt “Enter a number to be square rooted: “ input number approximation = 1 iteration = 0 while absolute value of approximation * approximation minus number is greater than EPSILON approximation = 0.5 * (approximation + number / approximation) iteration++ output “The square root of “ number “ is “ approximation output “The number of iterations needed were “ iteration prompt “Do you wish to continue?” input answer Translate 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 docstring comment in the beginning
The following is pseudocode to compute the square root of an inputted number, called number.
EPSILON = 1.0e-14
answer = “yes”
while answer[0] equals “Y” or answer[0] equals “y”
prompt “Enter a number to be square rooted: “
input number
approximation = 1
iteration = 0
while absolute value of approximation * approximation minus number
is greater than EPSILON
approximation = 0.5 * (approximation + number / approximation)
iteration++
output “The square root of “ number “ is “ approximation
output “The number of iterations needed were “ iteration
prompt “Do you wish to continue?”
input answer
Translate 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 docstring
comment in the beginning
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images