[Tutor] script comparing two values

alan.gauld@bt.com alan.gauld@bt.com
Tue Feb 25 06:34:02 2003


> This is what I have and I know that it is completely wrong:
> 
> def constant(j):
> 	result = []
> 	i = 0.0
> 	while i is not j:
> 		result.append(k)
> 		i, k = (k / (1 - k)((1 - k)^s) / (1 - (1 - k)^s), i
> + 0.0001

Try swapping these lines round. 
k doesn't exist till after the assignment...

Also:
i = (k / (1 - k)((1 - k)^s) / (1 - (1 - k)^s)
               ^^
             Should these be multiplied together?
If so you need to use the * operator, Python doesn't know about 
implicit multiplication ala math.

So taking the first term, should it be:

(k/(1-k)) * ((1-k)**s)/(1-(1-k)**s)

OR

(k/((1-k)*((1-k)**s)))/(1-(1-k)**s)

OR something else again....

HTH,

Alan G.