Advertisement
baggiepr

Rhys Y6 Orchard Lea Comments his Maths Quiz

Feb 6th, 2013
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. import random
  2. score=0#this tells you your score at the moment
  3. for i in range (10):
  4.     num1=random.randint(2,12)#int stands for integer (whole number)
  5.     num2=random.randint(2,12)#random whole number between 2 & 12
  6.     rightanswer=num1*num2#Python uses an * to multiply
  7.     print(num1,"X",num2,"= ?")#it shows the question to the user
  8.     choice=int(input("what is the answer?"))#a box where you decide the answer
  9.     print(choice)#Ask user to input a number as an answer to the question
  10.     if rightanswer == choice:#If answer variable is equal to (== means equals) choice variable
  11.         print("Correct")#it tells you when you get it right or not
  12.     else:#to see if you got it wrong
  13.         print("Incorrect")#tells you you have got it wrong
  14.     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