Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- score=0#this tells you your score at the moment
- for i in range (10):
- num1=random.randint(2,12)#int stands for integer (whole number)
- num2=random.randint(2,12)#random whole number between 2 & 12
- rightanswer=num1*num2#Python uses an * to multiply
- print(num1,"X",num2,"= ?")#it shows the question to the user
- choice=int(input("what is the answer?"))#a box where you decide the answer
- print(choice)#Ask user to input a number as an answer to the question
- if rightanswer == choice:#If answer variable is equal to (== means equals) choice variable
- print("Correct")#it tells you when you get it right or not
- else:#to see if you got it wrong
- print("Incorrect")#tells you you have got it wrong
- print("Your score so far is",score,"out of 10")#this tells you your score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement