Answer to Question #247581 in Python for Raymond Ekwubiri

Question #247581
CS 1101 Programming Fundamentals - AY2022-T1
Dashboard
My courses
CS 1101 - AY2022-T1
30 September - 6 October
Learning Guide Unit 5

Learning Guide Unit 5
Learning Guide Unit 5

Programming Assignment
This assignment is based on Exercise 7.1 from your textbook.

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
1
Expert's answer
2021-10-06T16:35:39-0400
def my_sqrt(a, x):
    while True:
        y = (x + a/x) / 2.0
        if y == x:
            break
        x = y
    return x
my_sqrt(25, 1)
5.0

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

ACHO BERNARD
09.12.21, 01:52

It's always good to do my findings with you people.

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS