Bird
0
0

Which of the following is the correct way to log a tool call and its result in a simple Python function?

easy📝 Syntax Q12 of 15
Agentic AI - Agent Observability
Which of the following is the correct way to log a tool call and its result in a simple Python function?
Adef log_call(tool_name, result): print(f"Tool {tool_name} result")
Bdef log_call(tool_name, result): return f"Tool {tool_name} returned {result}"
Cdef log_call(tool_name, result): print("Tool tool_name returned result")
Ddef log_call(tool_name, result): print(f"Tool {tool_name} returned {result}")
Step-by-Step Solution
Solution:
  1. Step 1: Check string formatting with variables

    def log_call(tool_name, result): print(f"Tool {tool_name} returned {result}") uses f-string correctly to insert variables tool_name and result.
  2. Step 2: Verify output method

    def log_call(tool_name, result): print(f"Tool {tool_name} returned {result}") prints the message, which is typical for logging in simple scripts.
  3. Final Answer:

    def log_call(tool_name, result): print(f"Tool {tool_name} returned {result}") -> Option D
  4. Quick Check:

    Correct f-string and print used [OK]
Quick Trick: Use f-strings and print() to log calls and results [OK]
Common Mistakes:
  • Not using f-string for variable insertion
  • Printing literal variable names instead of values
  • Returning string instead of printing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes