[Tutor] exercise (while loop)
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:
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...
More information about the Tutor