import random
# List of quiz questions and answers
quiz_data = [
{"question": "What is the capital of France?",
"options": ["A) Paris", "B) London", "C) Rome",
"D) Berlin"], "answer": "A"},
{"question": "Which planet is known as the
Red Planet?", "options": ["A) Earth", "B) Mars",
"C) Jupiter", "D) Venus"], "answer": "B"},
{"question": "Who wrote 'To Kill a
Mockingbird'?", "options": ["A) Harper Lee", "B)
J.K. Rowling", "C) Ernest Hemingway", "D)
Mark Twain"], "answer": "A"},
{"question": "What is the smallest prime
number?", "options": ["A) 0", "B) 1", "C) 2", "D)
3"], "answer": "C"},
{"question": "In which year did the Titanic
sink?", "options": ["A) 1912", "B) 1905", "C)
1920", "D) 1898"], "answer": "A"},
{"question": "What is the chemical symbol for
gold?", "options": ["A) Au", "B) Ag", "C) Fe", "D)
Hg"], "answer": "A"},
{"question": "Which country is home to the
kangaroo?", "options": ["A) India", "B)
Australia", "C) Brazil", "D) South Africa"],
"answer": "B"},
{"question": "How many continents are
there?", "options": ["A) 5", "B) 6", "C) 7", "D)
8"], "answer": "C"},
{"question": "Who painted the Mona Lisa?",
"options": ["A) Michelangelo", "B) Leonardo da
Vinci", "C) Pablo Picasso", "D) Vincent van
Gogh"], "answer": "B"},
{"question": "What is the square root of 64?",
"options": ["A) 6", "B) 7", "C) 8", "D) 9"],
"answer": "C"},
]
def run_quiz():
score = 0
answers = []
# Shuffle questions
[Link](quiz_data)
# Ask each question
for i, question_data in enumerate(quiz_data,
1):
print(f"\nQuestion {i}:
{question_data['question']}")
for option in question_data["options"]:
print(option)
user_answer = input("Your answer
(A/B/C/D): ").upper()
# Save the correct answer for later
[Link]((question_data['question'],
question_data['answer']))
# Check if the answer is correct
if user_answer ==
question_data["answer"]:
print("Correct!")
score += 1
else:
print(f"Wrong! The correct answer was
{question_data['answer']}")
# Display final results
print("\nQuiz Over!")
print(f"Your final score is:
{score}/{len(quiz_data)}\n")
# Show correct answers
print("Correct Answers:")
for question, correct_answer in answers:
print(f"{question}: {correct_answer}")
# Start the quiz
if __name__ == "__main__":
run_quiz()