On 01/04/2014 02:47, Danny Yoo wrote:

On Mar 31, 2014 6:22 PM, "Scott W Dunning" <scott....@cox.net
<mailto:scott....@cox.net>> wrote:
 >
 > I’m working on a few exercises and I’m a little stuck on this one.
 >
 > This is what the book has but it just gives me an endless loop.
 >
 > def square_root(a, eps=1e-6):
 >         while True:
 >                 print x
 >                 y = (x + a/x) / 2
 >                 if abs(y-x) < epsilon:
 >                         break
 >
 > round(square_root(9))

Hi Scott,

Ah.  I think I see what might be wrong, but let's make sure about this.

Can you explain what 'x', 'y' are in this function?


And the difference between eps and epsilon while (ouch) we're at it.

--
My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language.

Mark Lawrence

---
This email is free from viruses and malware because avast! Antivirus protection 
is active.
http://www.avast.com


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to