This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!
Guest

quiz

By: a guest on Nov 16th, 2012  |  syntax: None  |  size: 1.49 KB  |  views: 32  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. flashcards = ["not False:True", "not True:False", "True or False:True",
  2.     "True or True:True", "False or True:True", "False or False:False",
  3.     "True and False:False", "True and True:True", "False and True:False",
  4.     "False and False:False", "not (True or False):False", "not (True or True):False",
  5.     "not (False or True):False", "not (False or False):True",
  6.     "1 != 0:True", "1 != 1:False", "0 != 1:True", "0 != 0:False",
  7.     "1 == 0:False", "1 == 1:True", "0 == 1:False", "0 == 0:True"]
  8.    
  9. from random import shuffle
  10.    
  11. def splitcards(flashcards):
  12.     shuffle(flashcards)
  13.     question_list = []
  14.     answer_list = []
  15.     for x in flashcards:
  16.         statement, answer = x.split(':')
  17.         question_list.append(statement)
  18.         answer_list.append(answer)
  19.     return question_list, answer_list
  20.                
  21. def quiz1(flashcards):
  22.     count = int(input("How many questions would you like? \n>"))
  23.     print("Please answer 'True' or 'False'")
  24.     question_list, answer_list = splitcards(flashcards)
  25.     randq = 1
  26. #since I'm already shuffling the list, I decided to just use the count for the list position.
  27.     while count > 0:        
  28.                 questions = question_list[count]
  29.                 ans = input(questions + "\n> ")
  30.                 answers = answer_list[count]
  31.                 if ans == answers:
  32.                         print("Well done!")
  33.                 else:
  34.                         print("HA! You suck.")
  35.                 count -= 1
  36.  
  37.    
  38. quiz1(flashcards)
clone this paste RAW Paste Data