Oct-12-2017, 04:10 AM
I created a math question generator and I was wondering how do I make the function return the number of questions answered correctly?
For example (on line 6),
For example (on line 6),
primary_school_quiz(0,2) Question 1: What is the result of 3-10? -7 Question 2: What is the result of 10-7? 3 2This is my code:
quiz(flag, n): if flag == 0: for i in range (1,n+1): n1= random.randint(0,9) n2= random.randint(0,9) x= input('Question '+str(i)+':'+'\n'+'What is the result of '+str(n1)+'-'+str(n2)+'? ') elif flag == 1: for i in range (1,n+1): n1= random.randint(0,9) n2= random.randint(0,9) x= input('Question '+str(i)+':'+'\n'+'What is the result of '+str(n1)+'^'+str(n2)+'? ')