0
0
Prompt Engineering / GenAIml~20 mins

Tool usage (function calling) in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Function Calling Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Understanding function calling in AI tool usage

Which statement best describes the purpose of function calling in AI tools?

AIt is used to train the AI model by calling training functions repeatedly.
BIt automatically fixes bugs in the AI code without human intervention.
CIt allows the AI to request specific external actions or data by invoking predefined functions.
DIt generates random outputs without any input or function definitions.
Attempts:
2 left
💡 Hint

Think about how AI can interact with external systems or APIs.

Predict Output
intermediate
2:00remaining
Output of a function call in AI tool usage

What is the output of the following function call simulation in an AI tool?

Prompt Engineering / GenAI
def get_weather(city):
    return f"The weather in {city} is sunny."

result = get_weather('Paris')
print(result)
AThe weather in city is sunny.
BThe weather in Paris is sunny.
CThe weather in Paris is rainy.
DError: function get_weather not defined.
Attempts:
2 left
💡 Hint

Look at the function return string and the argument passed.

Model Choice
advanced
2:00remaining
Choosing the right function for AI tool usage

You want an AI tool to fetch the current stock price for a company. Which function call is most appropriate?

Afetch_stock_price(company_symbol: str) -> float
Btrain_stock_model(data: list) -> None
Cgenerate_random_number() -> int
Dsave_to_database(data: dict) -> bool
Attempts:
2 left
💡 Hint

Focus on the function that retrieves stock price information.

Hyperparameter
advanced
2:00remaining
Setting parameters for function calls in AI tools

When calling a function to generate text with an AI model, which parameter controls the randomness of the output?

Amax_depth
Bbatch_size
Clearning_rate
Dtemperature
Attempts:
2 left
💡 Hint

Think about which parameter affects creativity or randomness in generated text.

🔧 Debug
expert
2:00remaining
Debugging a function call error in AI tool usage

Given this function call in an AI tool, what error will it raise?

Prompt Engineering / GenAI
def get_user_info(user_id: int):
    return {'id': user_id, 'name': 'Alice'}

info = get_user_info('123')
print(info)
ANo error, prints {'id': '123', 'name': 'Alice'}.
BKeyError because 'name' key is missing.
CTypeError because a string was passed instead of an int.
DSyntaxError due to missing colon.
Attempts:
2 left
💡 Hint

Check the function parameter type and the argument passed.