Ask
your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW)
37 Online
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.
Still Need Help?
Join the QuestionCove community and study together with friends!
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!
Join our real-time social learning platform and learn together with your friends!
Latest Questions
addison123456:
There was one phone call, one moment, that completely changed my life. It was from someone who probably never knew the impact they had, but their words stuc
unknownnnnnn:
Hurt, Unlit... Hurt is a room with no windows, air thick with unsaid things. You pace the floor, counting breaths like debts you owe.
penguin:
idk what to do I'm in foster care and I used to do a lot of things like cut for i
Skeeter:
Does anyone have any big plans for New Years? What is your FAVORITE tradition for
unknownnnnnn:
Cuts... Some cuts are paper-thin, a day nicked by a word said wrong, a moment sharp enough to sting then fade.
penguin:
I thought it was a dream; I thought it wasn't real, But pain really hurts and it's really how I feel.
penguin:
Forever means nothing in my eyes. It's just a word you use to cover up lies, To hide your tracks each night you leave So I don't worry and start to believe.
xjacob:
Question why people that do art are good even though they don't like it and they don't do it.
1 hour ago
7 Replies
2 Medals
6 hours ago
0 Replies
0 Medals
10 hours ago
2 Replies
0 Medals
11 hours ago
10 Replies
0 Medals
12 hours ago
5 Replies
3 Medals
15 hours ago
3 Replies
0 Medals
1 day ago
2 Replies
0 Medals
1 day ago
2 Replies
2 Medals