[Tutor] Exercise in writing a python function.

John Fouhy 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][0] ** 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  >

Hi Kermit,

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
loop:

    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.
    Otherwise, ...

Hmm, actually, I'm not sure I do understand.  Does mpylist ever
change?  How is mult related to zlim?

-- 
John.


More information about the Tutor mailing list