Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random#This makes the question random
- score=0#This is a variable wich shows you your score
- for i in range(20):#This tells the computer to repeat 20 times
- num1=random.randint(2,12)#This is choosing a random number to put inside the variable num1
- num2=random.randint(2,12)#This is choosing a random number to put inside the variable num2
- rightanswer=num1*num2#This tells the computer to times the random num1 number by the random num2
- print(num1,"X",num2,"= ?")#The x means to times the num1 random number by the random number from num2
- choice=int(input("What is the answer?"))#This tells you to put in a answer
- if rightanswer == choice:#This tells the computer what to do if you are correct
- print("Correct")#This shows you that you are correct
- score=score+1#This increases your score
- else:#This tells the comuter to print incorrect
- print("Incorrect") #This means that the answer is incorrect and it just prints word incorrect
- print("your score is",score)#This sjows you what your score is
- print("your final score is",score,"out of 20 ")#THis prints your final score
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement