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 -
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,
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)
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
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
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:
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
Also, which book?
___
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor
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,
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
10 matches
Mail list logo