import random

# Define quiz questions and answers
quiz_questions = {
    "What is the capital of France?": ["a. Paris", "b. London", "c. Berlin", "d. Rome"],
    "What is the largest planet in our solar system?": ["a. Jupiter", "b. Saturn", "c. Mars", "d. Earth"],
    "Which is the tallest mammal?": ["a. Elephant", "b. Giraffe", "c. Hippopotamus", "d. Rhinoceros"],
    "What is the chemical symbol for water?": ["a. H2O", "b. CO2", "c. O2", "d. NaCl"]
}

# Define correct answers
correct_answers = {
    "What is the capital of France?": "a",
    "What is the largest planet in our solar system?": "a",
    "Which is the tallest mammal?": "b",
    "What is the chemical symbol for water?": "a"
}

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

# Function to play the quiz
def play_quiz(questions, num_questions):
    # Randomly select questions
    selected_questions = random.sample(list(questions.keys()), num_questions)
    score = 0
    # Ask each question
    for question in selected_questions:
        user_answer = ask_question(question, questions[question])
        if user_answer == correct_answers[question]:
            print("Correct!")
            score += 1
        else:
            print("Incorrect!")
            print("Correct answer:", correct_answers[question])
    # Display final score
    print("Your final score is:", score, "out of", num_questions)

# Main function
def main():
    print("Welcome to the Quiz Game!")
    num_questions = int(input("How many questions would you like to answer? "))
    play_quiz(quiz_questions, num_questions)

if __name__ == "__main__":
    main()