Ask Question
4 September, 18:46

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

+3
Answers (1)
  1. 4 September, 18:52
    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 and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers