import random score=0 question = 0 num1 = 0 num2 = 0 func = 0 print("Welcome to the Randomised Maths Quiz! Enter your name:") name = input() print("Thank you,",name,". Your test is about to begin.") print() while True: question = question + 1 num1 = random.randint(1,20) num2 = random.randint(1,20) func = random.randint(1,4) if func == 1: print("Q",question,") What is",num1,"times",num2,"?") if func == 2: print("Q",question,") What is",num1,"divided by",num2,"?") if func == 3: print("Q",question,") What is",num1,"add",num2,"?") if func == 4: print("Q",question,") What is",num1,"minus",num2,"?") answer = float(input()) if func == 1: if answer==(num1*num2): print("Correct!") score=score+1 else: print("Incorrect.") if func == 2: if answer==(num1/num2): print("Correct!") score=score+1 else: print("Wrong...") if func == 3: if answer==(num1+num2): print("Correct!") score=score+1 else: print("Think again.") if func == 4: if answer==(num1-num2): print("Correct!") score=score+1 else: print("Nope...") print(name,", your score so far is",score,"out of",question,".")
Not that anyone actually wants to do infinite maths... :p