[Tutor] exercise (while loop)
Mark Lawrence
breamoreboy at yahoo.co.uk
Tue Apr 1 11:09:34 CEST 2014
On 01/04/2014 02:47, Danny Yoo wrote:
>
> On Mar 31, 2014 6:22 PM, "Scott W Dunning" <scott.w.d at cox.net
> <mailto: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?
>
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
More information about the Tutor
mailing list