[Tutor] Exercise in writing a python function.
john at fouhy.net
Wed Aug 9 06:04:27 CEST 2006
On 09/08/06, Kermit Rose <kermit at polaris.net> wrote:
> Hello John.
> Thanks for replying.
> In my previous version, I used z as the critical value,.
> Since I created zlim, a function of z, to be passed in as a parameter, I no
> longer need z
> in the parameter list.
> In another part of the program, z is multiplied by
> product of mpylist[ k] ** mult[k] for k in range(len(mpylist)).
> I'm feeling something akin to writer's block when I sit down and attempt to
> start the code.
> I know that if I can just get started then the rest of the code will begin
> to flow in my thoughts.
> I did not really expect anyone to help me, but if you wish to indicate the
> first few lines of
> either python or psuedo code
> for this routine, it probably will help me get started.
> Kermit < kermit at polaris.net >
Your basic data structure is a list (actually, several related lists),
which you work your way through. So I would start off with a for
for k in range(len(mult)):
Then, in the body of the loop, your basic logic is:
Add 1 to mult[k].
If mult[k] is not too big, exit.
Hmm, actually, I'm not sure I do understand. Does mpylist ever
change? How is mult related to zlim?
More information about the Tutor