just a little program

David Brown david at no.westcontrol.spam.com
Thu Nov 7 09:50:41 EST 2002


"news.liwest.at" <christian.stockhammer at students.uni-linz.ac.at> wrote in
message news:1036679049.891080 at news.liwest.at...
> Hello List!
>
> I'm a student and i got a homework i just cannot solve: (I study
economics,
> so i'm absolutley out of programing)
>
> We have to write code that will do the following:
>
> You just put in any number and the program will multiply and divide this
> number from 2 to 9
>
> This is how it should look like:
>
>         13 *  2
>         26 *  3
>         78 *  4
>        312 *  5
>       1560 *  6
>       9360 *  7
>      65520 *  8
>     524160 *  9
>    4717440 :  2
>    2358720 :  3
>     786240 :  4
>     196560 :  5
>      39312 :  6
>       6552 :  7
>        936 :  8
>        117 :  9
>         13
>
> We have to define an own function like def something(input) and it should
be
> solved with a for-loop
>
> Any help would be appreciated
>
> Cheers and greetings from Austria
>

You mean, like:
def foo(x) :
    p = x
    for i in range(2, 10) :
        print "%d * %d = %d" % (p, i, p*i)
        p = p * i
    for i in range(2, 10) :
        print "%d / %d = %d" % (p, i, p/i)
        p = p / i

But why would you want to do this?  What does this have to do with
economics?  And why do you specifically want a for loop?







More information about the Python-list mailing list