[Tutor] exercise (while loop)
Danny Yoo
dyoo at hashcollision.org
Tue Apr 1 03:47:52 CEST 2014
On Mar 31, 2014 6:22 PM, "Scott W Dunning" <scott.w.d at 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?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140331/afd4758f/attachment.html>
More information about the Tutor
mailing list