Ask
your own question, for FREE!
MIT 6.00 Intro Computer Science (OCW)
42 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
xXAikoXx:
What needs to be done before choosing and reading a book? A. Make sure it is nonfiction.
gelphielvr:
(chemistry 2 questions) 1. Differentiate between the plum pudding model and the nuclear model for the atom.
gelphielvr:
(logistics) If the king does not castle and the Pawn advances then either the Bishop is blocked or the Rock is pinned.
Tylerr:
Does anyone know of any reputable websites offering scholarships, or where one ca
vannieduval:
Yall need to make a section for boredom and random thoughts
Jayisbetterfrfr:
Sometimes I beat up myself, I block my own way I cloud all my thoughts, please go
Luna34:
Mending Glass A heart once whole, now cracked and worn, Its edges sharp, its fabric torn, A silent cry, a whispered ache, From love once real, now past the
Luigi0210:
Bromine has 2 isotopes Br-79 and Br-81. The smaller isotope is 51% of the atoms on earth.
4 hours ago
2 Replies
1 Medal
7 hours ago
4 Replies
2 Medals
8 hours ago
17 Replies
2 Medals
9 hours ago
9 Replies
2 Medals
9 hours ago
9 Replies
0 Medals
4 hours ago
5 Replies
2 Medals
2 hours ago
4 Replies
3 Medals
1 day ago
9 Replies
4 Medals