import random

# Define a list of questions with their corresponding choices and answers
questions = [
    {
        "question": "What is the capital of France?",
        "choices": ["A. London", "B. Paris", "C. Rome", "D. Berlin"],
        "answer": "B"
    },
    {
        "question": "What is 2 + 2?",
        "choices": ["A. 3", "B. 4", "C. 5", "D. 6"],
        "answer": "B"
    },
    {
        "question": "What is the largest planet in our solar system?",
        "choices": ["A. Jupiter", "B. Saturn", "C. Mars", "D. Earth"],
        "answer": "A"
    }
]

def run_quiz(questions, num_questions):
    score = 0
    # Shuffle the questions to randomize their order
    random.shuffle(questions)
    # Select a specified number of questions for the quiz
    selected_questions = questions[:num_questions]

    # Iterate through each selected question
    for i, question in enumerate(selected_questions):
        print(f"Question {i+1}: {question['question']}")
        # Display the available choices
        for choice in question['choices']:
            print(choice)
        
        # Accept the player's answer
        player_answer = input("Enter your answer (A, B, C, or D): ").upper()
        
        # Check if the answer is correct
        if player_answer == question['answer']:
            print("Correct!")
            score += 1
        else:
            print("Incorrect!")

    # Display the final score
    print(f"You scored {score} out of {num_questions}")

# Run the quiz with 2 questions
run_quiz(questions, 2)
