[Tutor] Exercise in writing a python function.
Kermit Rose
kermit at polaris.net
Wed Aug 9 16:02:53 CEST 2006
From: Alan Gauld
Date: 08/09/06 03:30:28
To: Kermit Rose; tutor at python.org
Subject: Re: [Tutor] Exercise in writing a python function.
> The current specifications for the function are:
>
> def incr(mult,z,zlim,mpylist):
> # mult is a vector of exponents for the multipliers in mpylist.
> # z is a positive odd integer.
> # zlim is the upper bound critical value for the sum of (
> mpylist[k][0] *
> mpylist[k][1] )
Just to clarify what this means.
you have mpylist = [(2,3),(3,5),(5,7)]
So the products list is: [6,15,35]
So zlim in this case should be greater than the
sum of products: 6+15+35 = 56
*******
Oops. That is what I said.
I made a mistake in the specificiations.
I should have specified that
for this example
that
3*mult[0] + 5 * mult[1] + 7 * mult[2] must be < zlim.
>>>>>
# where kth multiplier is mpylist [k][0]
> # and kth multiplier index is mpylist [k][1]
Not sure what you mean by the multiplier index?
The sum above shows mpylist[k][1] being used in the multiplication,
not as an index?
******
Yes. It's confusing because of my mistake of confusing mpylist[k][1] with
mult[k].
>>>>
> # function incr returns the next value of vector mult.
I'm still not clear what mult does, your example above doesn't
refer to mult anywhere?
*****
Yes, another consequence of my mistake in the specifications.
Kermit < kermit at polaris.net >
More information about the Tutor
mailing list