import random

# Define a list of questions. Each question is a dictionary with the question text, choices, and the correct answer.
questions = [
    {
        "question": "What is the capital of France?",
        "choices": ["A: Paris", "B: Rome", "C: Madrid", "D: Berlin"],
        "answer": "A"
    },
    {
        "question": "What is the largest ocean?",
        "choices": ["A: Atlantic", "B: Indian", "C: Southern", "D: Pacific"],
        "answer": "D"
    },
    {
        "question": "Which planet is known as the Red Planet?",
        "choices": ["A: Earth", "B: Mars", "C: Jupiter", "D: Venus"],
        "answer": "B"
    },
    {
        "question": "In what year did the Titanic sink?",
        "choices": ["A: 1912", "B: 1911", "C: 1913", "D: 1914"],
        "answer": "A"
    }
]

def run_quiz(questions):
    score = 0
    # Shuffle the questions to get a random selection each game.
    random.shuffle(questions)
    for question in questions:
        print(question["question"])
        for choice in question["choices"]:
            print(choice)
        answer = input("Enter your answer (A, B, C, D): ").upper()
        if answer == question["answer"]:
            print("Correct!")
            score += 1
        else:
            print(f"Incorrect! The correct answer was {question['answer']}.")
        print()
    print(f"Your final score is: {score}/{len(questions)}")

if __name__ == "__main__":
    run_quiz(questions)
