I am trying to figure out how to add two random numbers together. I am making a maths game and I am importing random numbers to make up the equation, but because they are random I will need the programme to calculate the answer and give the player a correct or incorrect score. Here is my coding so far:
if "Addition":
easygui.msgbox ("Please enter the correct answer to earn a point, there are 10 questions in this quiz")
for number in range(0,20):
Figure1 = random.randrange(0,11)
Figure2 = random.randrange(0,11)
PlayerAnswer = easygui.enterbox ("What is " +str(Figure1)+ " + " +str(Figure2)+ "?")
if PlayerAnswer ==("+Figure1+" + "+Figure2+"):
AdditionAnswers += 1
easygui.msgbox ("Correct! Your score is "+str(AdditionAnswers))
else:
AdditionAnswers += 0
IncorrectAnswers += 1
easygui.msgbox ("Sorry, incorrect! Your score is still "+str(AdditionAnswers))
easygui.msgbox ("You scored " +str(AdditionAnswers)+ " out of 10")
I have tried turning the Figure1 and Figure2 into (+str(Figure1)+ " + " +str(Figure2)+"):
in the PlayerAnswer line, but that does not calculate it either đ Any help trying to figure this out will be really appreciated!! ❤️
Aucun commentaire:
Enregistrer un commentaire