From b1ad66d4f92157abfbdfaaf40c84df72d9b70a22 Mon Sep 17 00:00:00 2001 From: Donald Calloway Date: Thu, 16 Oct 2025 09:57:22 -0700 Subject: [PATCH] Adding quiz_game.py --- quiz_game.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 quiz_game.py diff --git a/quiz_game.py b/quiz_game.py new file mode 100644 index 0000000..9007b9e --- /dev/null +++ b/quiz_game.py @@ -0,0 +1,58 @@ +# Python Quiz Game + +questions = ("How many elements are in the periodic table?", + "Which animal lays the largest eggs?", + "What is the most abundant gas in the earth's atmosphere?", + "How many bones are in the human body?", + "Which planet in the solor system is the hottest?") + +options = (("A. 116", "B. 117", "C. 118 ", "D. 119"), + ("A. Whale", "B. Crocodile", "C. Elephant", "D. Ostrich"), + ("A. Nitrogen", "B. Oxygen", "C. Carbon Dioxide", "D. Hydrogen"), + ("A. 206", "B. 207", "C. 208", "D. 209"), + ("A. Mercury", "B. Venus", "C. Earth", "D. Mars")) + +answers = ("C", "D", "A", "A", "B") + +guesses = [] + +score = 0 +question_num = 0 + +# Display each question +for question in questions: + print("---------------------------------------------------------") + print(question) + +# Display every option + for option in options[question_num]: + print(option) + # Take user guess and move to the next question + guess = input("A, B, C, or D: ").upper() + guesses.append(guess) + if guess == answers[question_num]: + score += 1 + print("CORRECT ANSWER!") + else: + print("INCORRECT.") + print(f"{answers[question_num]} is the correct answer") + question_num += 1 + +# Print results + +print("-------------------------------") +print(" RESULTS ") +print("-------------------------------") + +print("answers: ", end="") +for answer in answers: + print(answer, end=" ") +print() + +print("guesses: ", end="") +for guess in guesses: + print(guess, end=" ") +print() + +score = int(score / len(questions) * 100) +print(f"Your score is: {score}%")