import random

# Define quiz questions and answers
quiz = [
    {
        "question": "What is the capital of France?",
        "options": ["a. Paris", "b. Rome", "c. Berlin", "d. London"],
        "answer": "a"
    },
    {
        "question": "What is 2 + 2?",
        "options": ["a. 3", "b. 4", "c. 5", "d. 6"],
        "answer": "b"
    },
    {
        "question": "Who wrote 'Romeo and Juliet'?",
        "options": ["a. William Shakespeare", "b. Charles Dickens", "c. Jane Austen", "d. Mark Twain"],
        "answer": "a"
    },
    {
        "question": "What is the chemical symbol for water?",
        "options": ["a. W", "b. Wa", "c. H2O", "d. Wt"],
        "answer": "c"
    }
]

# Function to display question and options
def display_question(question):
    print(question["question"])
    for option in question["options"]:
        print(option)
    print()

# Function to play the quiz
def play_quiz(quiz, num_questions):
    random.shuffle(quiz)
    score = 0
    for i in range(num_questions):
        print("Question", i + 1)
        display_question(quiz[i])
        user_answer = input("Enter your answer (a, b, c, or d): ").lower()
        if user_answer == quiz[i]["answer"]:
            print("Correct!")
            score += 1
        else:
            print("Incorrect!")
        print()
    print("Quiz complete!")
    print("Your score is", score, "out of", num_questions)

# Main function
def main():
    print("Welcome to the Quiz Game!")
    num_questions = int(input("Enter the number of questions you'd like to answer: "))
    play_quiz(quiz, num_questions)

if __name__ == "__main__":
    main()