could you check if the following code is ai generated def main():
    while True:
        choice = display_menu()
        if choice == '1':
            start_quiz()
        elif choice == '2':
            show_instructions()
        elif choice == '3':
            print("Thank you for playing! Goodbye!")
            break
        else:
            print("Invalid choice. Please select again.")

def display_menu():
    """Displays the main menu and returns the user's choice."""
    print("\nChoose:")
    print("1. Play")
    print("2. Game instructions")
    print("3. Exit")
    return input("Enter your choice: ")
import random

def start_quiz():
    """Starts the Math Quiz game."""
    difficulty = choose_difficulty()
    questions, correct_answers, user_answers = generate_questions(difficulty)
    correct_count = evaluate_answers(correct_answers, user_answers)
    show_results(correct_count, len(questions))

def choose_difficulty():
    """Allows the player to select a difficulty level."""
    print("\nSelect Difficulty Level:")
    print("1. Easy")
    print("2. Medium")
    print("3. Hard")
    choice = input("Enter your choice: ")
    if choice == '1':
        return "Easy"
    elif choice == '2':
        return "Medium"
    elif choice == '3':
        return "Hard"
    else:
        print("Invalid choice, defaulting to Easy.")
        return "Easy"

def generate_questions(difficulty):
    """Generates questions based on the selected difficulty."""
    num_questions = 5
    questions = []
    correct_answers = []
    user_answers = []

    for _ in range(num_questions):
        num1 = random.randint(1, 10)
        num2 = random.randint(1, 10)
        if difficulty == "Easy":
            operation = '+'
        elif difficulty == "Medium":
            operation = random.choice(['+', '-'])
        else:
            operation = random.choice(['+', '-', '*'])

        question = f"{num1} {operation} {num2}"
        answer = eval(question)  # Evaluate the string as a math expression
        questions.append(question)
        correct_answers.append(answer)
        
        try:
            user_input = int(input(f"Solve: {question} = "))
            user_answers.append(user_input)
        except ValueError:
            print("Invalid input, counted as incorrect.")
            user_answers.append(None)

    return questions, correct_answers, user_answers

def evaluate_answers(correct_answers, user_answers):
    """Evaluates the user's answers and returns the number of correct responses."""
    correct_count = 0
    for correct, user in zip(correct_answers, user_answers):
        if correct == user:
            correct_count += 1
    return correct_count

def show_results(correct_count, total_questions):
    """Displays the results and awards a medal based on performance."""
    print("\nGame Over!")
    print(f"You answered {correct_count} out of {total_questions} correctly.")
    
    if correct_count == total_questions:
        medal = "Gold"
    elif correct_count >= total_questions * 0.7:
        medal = "Silver"
    else:
        medal = "Bronze"
    
    print(f"Congratulations! You earned a {medal} medal.")

def show_instructions():
    """Displays the game instructions."""
    print("\nInstructions: Answer the math questions correctly to earn medals.")
    print("You can select different levels of difficulty.")
main()