[Tutor] my first project: a multiplication trainer

Guba listsdl04 at yahoo.de
Mon Mar 17 16:14:48 CET 2008


Dear Chris, list,

cheers for the great help: very valuable indeed.

Chris Fuller wrote:
######################
for proxyq in choices:
   q = questions[proxyq]
   answer = raw_input('%dx%d = ' % tuple(q))

   if int(answer) == q[0]*q[1]:
      print 'correct'
   else:
      print 'incorrect'
      false_answers.append(q)
######################

I was unable to find information on tuple(). (The Python help function
was rather conservative in its output, Google not helpful).
What exactly is the use of tuple(q) here, and why does not a simple q
instead of tuple(q) do? The latter would have been my intuitive
expectation...

The other thing I have on my mind is this: how could I have the program
ask the math questions not horizontally but vertically? An example:

 4
x7
=

instead of

4x7=

Thank you all,

Guba



More information about the Tutor mailing list