Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 18 Online
OpenStudy (anonymous):

x = 25 epsilon = 0.01 numGuesses = 0 ans = 0.0 while abs(ans**2 - x) >= epsilon and ans <= x: ans += 0.00001 numGuesses += 1 print 'numGuesses =', numGuesses if abs(ans**2 - x) >= epsilon: print 'Failed on square root of', x else: print ans, 'is close to square root of', x The way I am understanding this line of code is that in the while line of code, abs(ans**2 - x) >= epsilon, this statement is false so the while operation terminates before it can continue right? But both epsilon and ans have to be true for it to loop. Please someone help me out on this one.

OpenStudy (anonymous):

I finally figured it out. abs will make a -25.0 = 25.0

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Latest Questions
RAVEN69: My drawing so far is actually fire
1 week ago 9 Replies 2 Medals
PureSoulless: is staying at your friend's house while you're homeless legal.
2 weeks ago 5 Replies 1 Medal
whyjustwhy: i did that one TV girl trend with blake (aka @ShadowKid3)
1 week ago 12 Replies 2 Medals
whyjustwhy: i did that one TV girl trend with blake (aka @shadowkid3)
2 weeks ago 3 Replies 0 Medals
whyjustwhy: yo guys he can watch me sleep now (ignore dora)
3 weeks ago 24 Replies 1 Medal
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!