import random

# Define a dictionary of quiz questions and answers
quiz_questions = {
    "What is the capital of France?": ["a. Paris", "b. Rome", "c. Berlin", "d. London"],
    "What is the largest planet in our solar system?": ["a. Jupiter", "b. Mars", "c. Earth", "d. Saturn"],
    "Who wrote 'Romeo and Juliet'?": ["a. William Shakespeare", "b. Jane Austen", "c. Charles Dickens", "d. Mark Twain"]
}

# Function to ask questions and get user input
def ask_question(question, choices):
    print(question)
    for choice in choices:
        print(choice)
    answer = input("Enter your answer (a, b, c, or d): ").lower()
    return answer

# Function to check if the answer is correct
def check_answer(question, answer):
    correct_answer = question.split()[2]
    if answer == correct_answer:
        print("Correct!\n")
        return True
    else:
        print("Incorrect. The correct answer is", correct_answer.upper() + ".\n")
        return False

# Function to play the quiz game
def play_quiz(questions):
    score = 0
    num_questions = int(input("How many questions would you like to answer? "))
    selected_questions = random.sample(list(questions.keys()), num_questions)
    for question in selected_questions:
        user_answer = ask_question(question, questions[question])
        if check_answer(question, user_answer):
            score += 1
    print("Quiz complete! Your score is", score, "out of", num_questions)

# Main function
def main():
    print("Welcome to the Quiz Game!\n")
    play_quiz(quiz_questions)

if __name__ == "__main__":
    main()