Advertisement
baggiepr

Josie Y6 Hiltingbury Comments her Maths Quiz

Jan 30th, 2013
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.93 KB | None | 0 0
  1. score=0#this mean your score is 0
  2. for i in range(10):#this means do the questins 10 times through
  3.     import random#this means the question is random
  4.     num1=random.randint(2,12)#the computer picks a number between 2,12 and puts it in num 1
  5.     num2=random.randint(2,12)
  6.     rightanswer=num1*num2#they give the right answer to num 1 times num2
  7.     print(num1,"X",num2,"= ?")#the x means times the number and the ? that where you put the anwer
  8.     choice=int(input("What is the answer?"))#you put the answer where it says whats the answer
  9.     if rightanswer == choice:#if your choice is right
  10.         print("Correct")#this means your answer is correct
  11.  
  12.         score=score+1#adds to your score +1
  13.     else:
  14.         print("Incorrect")#I think this means the answer is incorrect.
  15.     print("Your score so far is",score)#shows your score and how well your doing
  16. print("Your score so far is",score,"out of 10")#shows your score out of ten
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement