Ask Question
29 September, 23:04

Encapsulate the following Python code from Section 7.5 in a function called 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:

a. y = (x + a/x) / 2.0

b. if y = = x:

c. break

d. x = y

+2
Answers (1)
  1. 29 September, 23:07
    0
    def my_sqrt (a):

    while True:

    x = a

    y = (x + a / x) / 2

    if (y = = x):

    break

    else:

    x = y

    print (x)

    return 0

    my_sqrt (5)

    Explanation:

    The above is a function in Python, and the exact copy as code of what is being given in the question. Its a method to find out the square root of a number which is a here. The while loop has been used as being mentioned in the question, and the variables are defined and calculated as being stated.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Encapsulate the following Python code from Section 7.5 in a function called my_sqrt that takes a as a parameter, chooses a starting value ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers