Re: [Tutor] exercise (while loop)

2014-04-01 Thread Scott W Dunning
On Mar 31, 2014, at 7:10 PM, Danny Yoo d...@hashcollision.org wrote: Thanks for the info Danny! I’ll try that and I should be able to figure it out with your help! The book I was referring to is greentreepress. ___ Tutor maillist -

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Mark Lawrence
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,

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Dave Angel
Scott W Dunning scott@cox.net Wrote in message: 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)

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Alan Gauld
On 01/04/14 02:07, Scott W Dunning 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

Re: [Tutor] exercise (while loop)

2014-04-01 Thread Danny Yoo
So this call will always try to round None(the default return value) And of course it produces no output since it prints nothing. Are you sure that's actually what is in the book? No. That's very much why I wanted a reference to the original source of the problem. Scott attributed too much

[Tutor] exercise (while loop)

2014-03-31 Thread Scott W Dunning
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:

Re: [Tutor] exercise (while loop)

2014-03-31 Thread Danny Yoo
On Mar 31, 2014 6:22 PM, Scott W Dunning 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

Re: [Tutor] exercise (while loop)

2014-03-31 Thread Danny Yoo
Also, which book? ___ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor

Re: [Tutor] exercise (while loop)

2014-03-31 Thread Danny Yoo
I tweaked it to what I thought was correct but when I test it I get nothing back. def square_root(a, eps=1e-6): x = a/2.0 while True: y = (x + a/x)/2.0 if abs(x - y) eps: return y x = y round(square_root(9)) The way I tweaked it seems to work,

Re: [Tutor] exercise (while loop)

2014-03-31 Thread Danny Yoo
On Mon, Mar 31, 2014 at 8:48 PM, Scott W Dunning scott@cox.net wrote: On Mar 31, 2014, at 7:10 PM, Danny Yoo d...@hashcollision.org wrote: Thanks for the info Danny! I’ll try that and I should be able to figure it out with your help! The book I was referring to is greentreepress. The