Ask your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW) 41 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
happyday09: I drew this in a psych ward, lmk what u think
34 minutes ago 3 Replies 2 Medals
0bubz0: what should I do to my new JDM?
1 hour ago 2 Replies 0 Medals
Z1ah: Math
3 hours ago 8 Replies 1 Medal
JesusReyes: my life summed up
4 hours ago 12 Replies 1 Medal
Redfox123: what is acid made out of
3 hours ago 7 Replies 6 Medals
Redfox123: what cam first the color orange or the orange itself????
4 hours ago 4 Replies 0 Medals
Redfox123: what is acid made out of
5 hours ago 0 Replies 0 Medals
Countless7Echos: Bob ross really got my painter ego on, touching paper again yips :3 how I do (it'
46 minutes ago 13 Replies 5 Medals
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!