Bird
0
0

What will be the output of this code?

medium📝 Command Output Q5 of 15
Agentic AI - Agent Observability
What will be the output of this code?
def log_call(tool, result):
    print(f"Tool: {tool}")
    print(f"Result length: {len(result)}")

log_call('DeployTool', 'Failed')
AError: len() cannot be used on strings
BTool: DeployTool Result length: 6
CTool: DeployTool Result length: 0
DTool: DeployTool Result length: Failed
Step-by-Step Solution
Solution:
  1. Step 1: Understand len() on string

    len() returns the number of characters in the string 'Failed', which is 6.
  2. Step 2: Substitute values and check output

    Prints 'Tool: DeployTool' and 'Result length: 6' as in Tool: DeployTool Result length: 6.
  3. Final Answer:

    Tool: DeployTool Result length: 6 -> Option B
  4. Quick Check:

    len('Failed') = 6 characters [OK]
Quick Trick: len() counts characters in strings [OK]
Common Mistakes:
  • Thinking len() returns string
  • Assuming len() is zero
  • Believing len() causes error on strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes