Advertisement
trds

quizz

May 14th, 2021
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.77 KB | None | 0 0
  1. import time
  2. name = input("What is your name? \n")
  3. age = input("How old are you? \n")
  4. sex = input("What is your gender? \n")
  5.  
  6. general_culture_questions = 'General Questions'
  7. animals_questions = 'Animals Questions'
  8. capitals_questions = 'Capitals Questions'
  9. math_questions = 'Math Questions'
  10. geography_questions = 'Geography Questions'
  11. logical_questions = 'Logical Questions'
  12.  
  13. score=0
  14. questions = [general_culture_questions, animals_questions, capitals_questions, math_questions, geography_questions, logical_questions]
  15.  
  16. print(f"Hello {name}. Good Luck!")
  17. print ("Are you ready to begin?")
  18. input ("Press Enter when you are ready to begin...")
  19.  
  20. print("Welcome to the General Culture Questions Quiz 1")
  21. time.sleep(3)
  22. print ("Note: You must answer using A, B, C or D")
  23. time.sleep(3)
  24. print (" ")
  25. class Question:
  26.     def __init__(self, prompt, answer):
  27.         self.prompt = prompt
  28.         self.answer = answer
  29.  
  30. question_prompts = [
  31.     "Q1: How many days are there in a normal year?\n(a) 365\n(b) 366\n(c) 362\n(d) 368\n\n",
  32.     "Q2: Which month of the year has the least number of days?\n(a) June\n(b) February\n(c) July\n(d) May\n\n",
  33.     "Q3: How many weeks are there in one year?\n(a) 51\n(b) 54\n(c) 53\n(d) 52\n\n",
  34.     "Q4: Which is the nearest star to planet earth?\n(a) Sun\n(b) Moon\n(c) Mars\n(d) Jupiter\n\n",
  35.     "Q5: Which day is observed as World Environment Day?\n(a) 5 July\n(b) 2 August\n(c) 5 June\n(d) 12 September\n\n",
  36.     "Q6: Who invented the Computer?\n(a) Mark Zuckerberg\n(b) Bill Gates\n(c) Steve Jobs\n(d) Charles Babbage\n\n",
  37.     "Q7: How many teeth does a healthy adult have including the wisdom teeth?\n(a) 32\n(b) 34\n(c) 30\n(d) 33\n\n",
  38.     "Q8: How many strings does a violin have?\n(a) 6\n(b) 8\n(c) 4\n(d) 12\n\n",
  39.     "Q9: How many planets are there in our solar system?\n(a) 8\n(b) 6\n(c) 10\n(d) 9\n\n",
  40.     "Q10: How many days are there in the month of February in a leap year?\n(a) 28\n(b) 29\n(c) 30\n(d) 27\n\n",
  41. ]
  42. questions = [
  43.     Question(question_prompts[0], "a"),
  44.     Question(question_prompts[1], "b"),
  45.     Question(question_prompts[2], "a"),
  46.     Question(question_prompts[3], "d"),
  47.     Question(question_prompts[4], "c"),
  48.     Question(question_prompts[5], "d"),
  49.     Question(question_prompts[6], "a"),
  50.     Question(question_prompts[7], "c"),
  51.     Question(question_prompts[8], "a"),
  52.     Question(question_prompts[9], "a"),
  53.  
  54. ]
  55.  
  56. def run_quiz(questions):
  57.     score = 0
  58.     for question in questions:
  59.         answer = input(question.prompt)
  60.         if answer == question.answer:
  61.             score += 1
  62.     print("you got", score, "out of", len(questions))
  63.  
  64.  
  65. run_quiz(questions)
  66. score=int()
  67.  
  68. print("Are you ready for the next step quiz?")
  69. input ("Press any key to continue...")
  70. print("Welcome to the General Culture Questions Quiz 2 - Capital Questions")
  71. print("Question 1")
  72. input ("Press any key to continue...")
  73. Question1 = input ("What is the capital of Italy? \n")
  74. if Question1 == ("Rome") or Question1 == ("rome"):
  75.     print("Correct answer")
  76.     score += 1
  77. else:
  78.     print("Incorrect answer, the correct answer is Rome")
  79. time.sleep(1)
  80.  
  81. print("Question 2")
  82. time.sleep(1)
  83. Question2 = input ("What is the capital of France? \n")
  84. if Question2 == ("Paris") or Question2 == ("paris"):
  85.     print("Correct answer")
  86.     score += 1
  87. else:
  88.     print("Incorrect answer, the correct answer is Paris")
  89.  
  90. print("Question 3")
  91. time.sleep(3)
  92. Question2 = input ("What is the capital of Germany? \n")
  93. if Question2 == ("Berlin") or Question2 == ("berlin"):
  94.     print("Correct answer")
  95.     score += 1
  96. else:
  97.     print("Incorrect answer, the correct answer is Berlin")
  98.  
  99. print("Question 4")
  100. time.sleep(1)
  101. Question2 = input ("What is the capital of Romania? \n")
  102. if Question2 == ("Bucharest") or Question2 == ("bucharest"):
  103.     print("Correct answer")
  104.     score += 1
  105. else:
  106.     print("Incorrect answer, the correct answer is Bucharest")
  107.  
  108. print("Question 5")
  109. time.sleep(1)
  110. Question2 = input ("What is the capital of China? \n")
  111. if Question2 == ("Beijing") or Question2 == ("beijing"):
  112.     print("Correct answer")
  113.     score += 1
  114. else:
  115.     print("Incorrect answer, the correct answer is Beijing \n")
  116.  
  117. print("Question 6")
  118. time.sleep(1)
  119. Question2 = input ("What is the capital of Afghanistan? \n")
  120. if Question2 == ("Kabul") or Question2 == ("kabul"):
  121.     print("Correct answer")
  122.     score += 1
  123. else:
  124.     print("Incorrect answer, the correct answer is Kabul \n")
  125.  
  126. print("Question 7")
  127. time.sleep(1)
  128. Question2 = input ("What is the capital of Brazil? \n")
  129. if Question2 == ("Brasilia") or Question2 == ("brasilia"):
  130.     print("Correct answer")
  131.     score += 1
  132. else:
  133.     print("Incorrect answer, the correct answer is Brasilia")
  134.  
  135. print("Question 8")
  136. time.sleep(1)
  137. Question2 = input ("What is the capital of England? \n")
  138. if Question2 == ("London") or Question2 == ("london"):
  139.     print("Correct answer")
  140.     score += 1
  141. else:
  142.     print("Incorrect answer, the correct answer is London")
  143.  
  144. print("Question 9")
  145. time.sleep(1)
  146. Question2 = input ("What is the capital of Iraq? \n")
  147. if Question2 == ("Baghdad") or Question2 == ("baghdad"):
  148.     print("Correct answer")
  149.     score += 1
  150. else:
  151.     print("Incorrect answer, the correct answer is Baghdad")
  152.  
  153. print("Question 10")
  154. time.sleep(1)
  155. Question2 = input ("What is the capital of Monaco? \n")
  156. if Question2 == ("Monaco") or Question2 == ("monaco"):
  157.     print("Correct answer")
  158.     score += 1
  159. else:
  160.     print("Incorrect answer, the correct answer is London")
  161.  
  162. print("You got",(score),"/ 10")
  163. num1 = (score)
  164. num2 = 10
  165. print('{0:.2f}%'.format((num1 / num2 * 100)))
  166.  
  167. print("Are you ready for the next step quiz?")
  168. input ("Press any key to continue...")
  169. print("Welcome to the General Culture Questions Quiz 3 - Logical Questions")
  170. print("Question 1")
  171. input ("Press any key to continue...")
  172.  
  173. def tf_quiz(question, correct_ans):
  174.     if input("(T/F) " + question + ": ") == correct_ans:
  175.         return("correct")
  176.     else:
  177.         return("incorrect")
  178.  
  179. print ("Note: T is for True and F is for False")
  180. print ("You must answer by T or F")
  181. time.sleep(3)
  182.  
  183. quiz_eval = tf_quiz("Despite their brain size, elephant memory is short-lived.", "F")
  184. quiz_eval = tf_quiz("Penguins can't be found on the continent of Africa.", "F")
  185. quiz_eval = tf_quiz("Horses can sleep standing up.", "T")
  186. quiz_eval = tf_quiz("The Amazon River has native dolphins.", "T")
  187. quiz_eval = tf_quiz("Camels store water in their humps.", "F")
  188. quiz_eval = tf_quiz("Female reindeer have antlers.", "T")
  189. quiz_eval = tf_quiz("Birds can fly.", "T")
  190. quiz_eval = tf_quiz("You can’t teach an old dog new tricks.", "F")
  191. quiz_eval = tf_quiz("Zebrafish can suffer from insomnia?", "T")
  192. quiz_eval = tf_quiz("Bats are not blind.", "T")
  193.  
  194. print("You got",(score),"/ 10")
  195. num1 = (score)
  196. num2 = 10
  197. print('{0:.2f}%'.format((num1 / num2 * 100)))
  198.  
  199.  
  200.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement