Advertisement
Guest User

quiz

a guest
Nov 16th, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement