Advertisement
okelikai

Student Created Quiz

Apr 27th, 2016
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.94 KB | None | 0 0
  1. import os
  2. user_name = raw_input("Welcome to Quiz #6, please input your name: \n")
  3. print "Okay %s! Let\'s start!" % user_name
  4.  
  5. def question_one(user_grade):
  6. print """
  7. 1. What does the return statement do?
  8. a. Prints something
  9. b. Calls a function
  10. c. Prints and returns to the calling function
  11. d. Returns to the beginning of a function
  12. """
  13. input_answer_one = raw_input("What is your answer?\n")
  14. if input_answer_one == 'c':
  15. os.system('clear')
  16. user_grade = user_grade + 1
  17. question_two(user_grade)
  18. else:
  19. os.system('clear')
  20. question_two(user_grade)
  21.  
  22. def question_two(user_grade):
  23. print """
  24. 2. What will "false or false" give you?
  25. a. True
  26. b. False
  27. c. False and true
  28. d. False and false
  29. """
  30. input_answer_two = raw_input("What is your answer?\n")
  31. if input_answer_two == "b":
  32. os.system('clear')
  33. user_grade = user_grade + 1
  34. question_three(user_grade)
  35. else:
  36. os.system('clear')
  37. question_three(user_grade)
  38.  
  39. def question_three(user_grade):
  40. print """
  41. 3. What will "not true and false" give you?
  42. a. True
  43. b. False
  44. c. Error
  45. d. True and False
  46. """
  47. input_answer_three = raw_input("What is your answer?\n")
  48. if input_answer_three == "a":
  49. os.system('clear')
  50. user_grade + 1
  51. question_four(user_grade)
  52. else:
  53. os.system('clear')
  54. question_four(user_grade)
  55.  
  56. def question_four(user_grade):
  57. print """
  58. 4. 0 != 0
  59. a. True
  60. b. False
  61. c. 0
  62. d. Error
  63. """
  64. input_answer_four = raw_input("What is your answer?\n")
  65. if input_answer_four == "b":
  66. os.system('clear')
  67. user_grade + 1
  68. question_five(user_grade)
  69. else:
  70. os.system('clear')
  71. question_five(user_grade)
  72.  
  73. def question_five(user_grade):
  74. print """
  75. 5. What does += do?
  76. a. Adds to the original integer
  77. b. Sets a sum equal to a new value
  78. c. Signifies if a sum is equal to a number, the code will execute something
  79. d. Adds two of the same numbers
  80. """
  81. input_answer_five = raw_input("What is your answer?\n")
  82. if input_answer_five == "a":
  83. os.system('clear')
  84. user_grade + 1
  85. question_six(user_grade)
  86. os.system('clear')
  87. else:
  88. os.system('clear')
  89. question_six(user_grade)
  90.  
  91. def question_six(user_grade):
  92. print """
  93. 6. What output would you get for this statement:
  94. y = 2
  95. x = 3 += y
  96. Print x
  97. a. 3+y
  98. b. 3y
  99. c. 5
  100. d. 2
  101. """
  102. input_answer_six = raw_input("What is your answer?\n")
  103. if input_answer_six == 'c':
  104. os.system('clear')
  105. user_grade = user_grade + 1
  106. question_seven(user_grade)
  107. else:
  108. os.system('clear')
  109. question_seven(user_grade)
  110.  
  111. def question_seven(user_grade):
  112. print """
  113. 7. What is the difference between '==' and '=' ?
  114. a. They both do the same thing
  115. b. == means not equal to, while = simply means equal to
  116. c. == globally sets a variable equal to something
  117. d. = sets a variable equal to something, == simply means something is equal to something else in that instance.
  118. """
  119. input_answer_seven = raw_input("What is your answer?\n")
  120. if input_answer_seven == "d":
  121. os.system('clear')
  122. user_grade = user_grade + 1
  123. question_eight(user_grade)
  124. else:
  125. os.system('clear')
  126. question_eight(user_grade)
  127.  
  128. def question_eight(user_grade):
  129. print """
  130. 8. What line is the error in this code on?
  131. 1: x = raw_input("What is the time?")
  132. 2: int(raw_input)
  133. 3: if x < 10:
  134. 4: print "Good morning"
  135. 5: elif x < 12:
  136. 6: print "Soon time for lunch"
  137. 7: elif x < 18:
  138. 8: print "Good day"
  139. 9: elif x < 22:
  140. 10: print "Good evening"
  141. 11: else:
  142. 12: print "Good night"
  143. """
  144. input_answer_eight = raw_input("What is your answer?\n")
  145. if input_answer_eight == "2":
  146. os.system('clear')
  147. user_grade = user_grade + 1
  148. question_nine(user_grade)
  149. else:
  150. os.system('clear')
  151. question_nine(user_grade)
  152.  
  153. def question_nine(user_grade):
  154. print """
  155. 9. What line is the error in this code on?
  156. 1: allowed_users = ['bill', 'steve']
  157. 2: username = raw_input("What is your login? : ")
  158. 3: if username is allowed_users:
  159. 4: print "Access granted"
  160. 5: else:
  161. 6: print "Access denied"
  162. """
  163. input_answer_nine = raw_input("What is your answer?\n")
  164. if input_answer_nine == "3":
  165. os.system('clear')
  166. user_grade = user_grade + 1
  167. question_ten(user_grade)
  168. else:
  169. os.system('clear')
  170. question_ten(user_grade)
  171.  
  172. def question_ten(user_grade):
  173. print """
  174. 10. What does this code do?
  175. for x in range(1,50):
  176. even_check = x / 2
  177. print even_check
  178. a. Prints all the whole numbers that would be given if you divided the range by 2 excluding 50
  179. b. Prints all numbers divided by 2
  180. c. Prints all numbers in the range
  181. d. Prints all the numbers that would would be given if you divided by 2 including 50
  182. """
  183. input_answer_ten = raw_input("What is your answer?\n")
  184. if input_answer_ten == "a":
  185. os.system('clear')
  186. user_grade = user_grade + 1
  187. quiz_end(user_grade)
  188. else:
  189. os.system('clear')
  190. quiz_end(user_grade)
  191.  
  192. def quiz_end(user_grade):
  193. print "Okay %s, you got a %s out of 10" % (user_name, user_grade)
  194. if user_grade > 6:
  195. print "You passed the quiz!"
  196. else:
  197. print "You failed the quiz, Study more next time!"
  198. question_one(0) # starts the quiz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement