Hi so basically I need to create a timer for this simple maths test. I need it to give each question, lets say 30 seconds for test purposes, and then move onto the next question after the time is up and repeat the timer like that. Just cant figure it out. Im new to python, any help is greatly appreciated. Here is my code
import random
correct = 0
incorrect = 0
for i in range(10):
number1 = random.randint(1,10)
number2 = random.randint(1,10)
question = (number1 * number2)
answer = int (input("What's %d times %d? " % (number1, number2)))
if answer == question:
print ("That's right", name,"! Well done.\n")
correct = correct + 1
else:
print ("No, I'm afraid the answer is %d.\n" % question)
incorrect = incorrect + 1
print ("\nYou answered 10 questions. You got %d right and %d wrong." % (correct, incorrect))
if correct >=5:
print ("Good job!")
else:
print ("Try harder next time! You got", incorrect, "answers wrong.")