MAX = 9

# separate the logic from the interface
# (so one could make a nicer interface later)
print '** Separation of Interface **'

from random import shuffle

questions = [ [i,j] for i in range(1,MAX+1) for j in range(1,MAX+1) ]
choices = range(len(questions))
shuffle(choices)

false_answers = []

def get_choice():
   if choices:
      return questions[choices.pop()]
   else:
      return None

def check_answer(q, answer):
   if answer == q[0]*q[1]:
      return True
   else:
      false_answers.append(q)

while True:
   q = get_choice()
   if not q:
      break

   while True:
      try:
         answer = int(raw_input('%dx%d = ' % tuple(q)))
      except ValueError:
         print 'enter an integer'
      else:
         break

   if check_answer(q, answer):
      print 'correct'
   else:
      print 'incorrect'

print 'You have answered all questions!'
