code: def _generate_question(self):
          
          x = random.randint(1, 10)
          y = random.randint(1, 10)
  
          operator = random.choice(('+', '-', '*',))
          if operator == '+':
              answer = x + y
          elif operator == '-':
              # Ensure we'll get a non-negative answer
              if x < y:
                  x, y = y, x
              answer = x - y
          else:
              # Multiplication is hard, make it easier
              x = math.ceil(x/2)
              y = math.ceil(y/2)
  
              answer = x * y
              # Use a prettied-up HTML multiplication character
              operator = '&times;'
  
          # Format the answer nicely, then mark it as safe so Django won't escape it
          question = '{} {} {}'.format(x, operator, y)
          return mark_safe(question), answer
docs: Generate a random arithmetic question
  
          This method randomly generates a simple addition, subtraction, or
          multiplication question with two integers between 1 and 10, and then
          returns both question (formatted as a string) and answer.