title: Randomly generating math questions
body: <p>My task is to produce a code that greets the user and asks their name  storing their name as <code>username</code>. Then generates 2 random numbers and an operation. The question is asked to the user. After that it checks if the users answer is correct or not also adding <code>1</code> to <code>questionsAsked</code>. If it is correct, <code>1</code> is added to <code>correctAnswers</code>. If it is incorrect, the user is told so with the correct answer. The program should end after 10 questions (hence the <code>while questionAsked &gt; 11</code>). The user should be given their <code>username</code> and how many questions they got correct.</p>
  
  <p>My problem is when I run the code,it comes up with <code>NameError: name 'questionAsked' is not defined</code>. I'm struggling to work out how else I could define <code>questionAsked</code>.</p>
  
  <p>Here is what I've done so far:</p>
  
  <pre><code>import random
  import math
  
  def test():
      Username=input("What is your name?")
      print ("Welcome"+Username+" to the Arithmetic quiz")
  
      num1=random.randint(1, 10)
      num2=random.randint(1, 10)
  
      Ops = ['+','-','*']
      Operation = random.choice(ops)
  
      num3=int(eval(str(num1) + operation + str(num2)))
  
      print("What is" +" "+str(num1) + operation +str (num2,"?"))
      userAnswer= int(input("Your answer:"))
      if userAnswer != num3:
          print("Incorrect. The right answer is"+" "+(num3))
          return False
  
      else:
          print("correct")
          return True
  
  correctAnswers=0
  questionsAsked=0
  while questionAsked &gt; 11:
      if test () == True: 
          questionsAnswered +=1
          correctAnswers +=1
      if test () == False: 
         questionsAnswered +=1
  </code></pre>