Advertisement
baggiepr

Bella in Year 6 Comments on her Maths Quiz

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