Re: time function problem

2008-11-28 Thread MRAB
willie wrote: My code: from time import time def leibniz(terms): acc = 0.0 num = 4.0 # numerator value remains constant in the series den = 1 count = 0 start_time = 0.0 for aterm in range(terms): nextterm = num/den * (-1)**aterm # (-1) allows fractions to alter

Re: time function problem

2008-11-27 Thread Steven D'Aprano
On Thu, 27 Nov 2008 11:17:04 -0800, willie wrote: > My code: > > from time import time > def leibniz(terms): > > > acc = 0.0 > num = 4.0 # numerator value remains constant in the series den = 1 > count = 0 > start_time = 0.0 This line is wrong. You're starting your timer at the

Re: time function problem

2008-11-27 Thread Diez B. Roggisch
willie wrote: > My code: > > from time import time > def leibniz(terms): > > > acc = 0.0 > num = 4.0 # numerator value remains constant in the series > den = 1 > count = 0 > start_time = 0.0 > for aterm in range(terms): > nextterm = num/den * (-1)**aterm # (-1)

time function problem

2008-11-27 Thread willie
My code: from time import time def leibniz(terms): acc = 0.0 num = 4.0 # numerator value remains constant in the series den = 1 count = 0 start_time = 0.0 for aterm in range(terms): nextterm = num/den * (-1)**aterm # (-1) allows fractions to alternate