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
Comments
It's always good to do my findings with you people.
Leave a comment