I have been trying to make a mathimatical quiz that asks a random question then asks another random question for a range of 10 times, what my problem is is that it will ask a random question then the same question again and again and again etc.
import random
opList = ["+", "*", "-"]
numberofQuestions = 10
num1 = random.randint(0, 10)
num2 = random.randint(0, 10)
ops = random.choice(opList)
question = "%d %s %d" % (num1, ops, num2)
answer = eval(question)
totalScore = 0
childName = input("Enter your name: ")
print("Thank you for signing up for Arithmetic Quiz " + childName)
for i in range(numberofQuestions):
reply = int(input("What is " + question + " ? "))
if reply == answer:
print("Correct!!")
totalScore += 1
else:
print("Incorrect!!")
Aucun commentaire:
Enregistrer un commentaire