Advertisement
trds

Untitled

Jul 22nd, 2021
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.63 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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement