Advertisement
baggiepr

Arun Y6 Orchard Lea Comments his code

Feb 6th, 2013
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.03 KB | None | 0 0
  1. import random # when you're playing the quiz it changes the numbers.
  2.  
  3. score=0 # it tells you what your score is at the beginning.
  4. for i in range(15): #how many times it will repeat.
  5.     num1=random.randint(2,12)
  6.     num2=random.randint(2,12)
  7. #print(num1,num2)
  8.     rightanswer=num1*num2
  9. #print(num1,num2,rihgtanswer)
  10.     print(num1,"x",num2,"=?")
  11.     choice=int(input("What is the answer?")) #a tab will come up and it will say (what is the anwser) then you put the a number then enter it.
  12. #print(choice)
  13.     if rightanswer == choice:
  14.      print("correct") #if the anser is right it will come up with correct.
  15.      score=score+1 #it adds a point if you get the anwser correct.
  16.     else:
  17.         print("incorrect")#when a anwser is wrong it will come up with incorrect.
  18.     print("your score so far is",score,"out of 15")
  19. print("your final scossssssssssssssssssssre is",score) #the score you get at the end and says what score you got out of the number you put in i in range like 15 then it will tell you what score yo've got out of 15.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement