[Tutor] How do I go about this? [was Re: Who uses input()? [was Re: question on "input"]]

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Thu Jul 28 01:39:59 CEST 2005



> I first posted my question in this post, but no one seemed to answer me.
> >
> >  It sure did, though I wish there was an easier way of coding it than
> > int(raw_input())! Any ideas would gladly be appreciated.

Hi Nathan,

About the question about int(raw_input()) being a bit verbose, Brian did
mention that we can define helper functions to make things less painful.
Personal function definitions like this can be very useful: we don't
always have to work at a primitive level, but can build on larger
concepts.

His suggested get_int() function:

    http://mail.python.org/pipermail/tutor/2005-July/039855.html

looks a bit big at first, but we can define it once, store it in a
personal library somewhere, and then it'll be available for us from then
on.


> > By the way, is there any code floating out there that can show how
> > many possible mixtures there are, e.g. for x0, x1, x2, x3, and a0, a1,
> > a2, and a3 for example.

I think people were a little confused what you meant here; can you give us
more ideas of what this is for?  "Mixture" in English means so many things
that it's hard to give concrete answers without seeing more what you mean.


Good luck!



More information about the Tutor mailing list