My task is to create a program that randomly selects a math question (*/+/-) from a bank of questions, then the user inputs an answer and finally the computer tells the user if the answer was correct or not. I need to know how to go about doing this and how to ask the user a random question. I so far have:
>>> choice = random.choice(["2*2","4+6","9-2"])
>>> answer = eval(choice)
>>> useranswer = input()
>>> if useranswer == answer:
print("correct")
else:
print("incorrect")
Aucun commentaire:
Enregistrer un commentaire