Bird
0
0

Identify the error in this observability code snippet:

medium📝 Debug Q6 of 15
Agentic AI - Agent Observability
Identify the error in this observability code snippet:
def log_metrics(metrics):
    print("Metrics:", metrics)

log_metrics = {'accuracy': 0.9}
ANo error, code runs fine
BPrint statement syntax is incorrect
CDictionary syntax is invalid
DFunction name overwritten by dictionary, causing error on call
Step-by-Step Solution
Solution:
  1. Step 1: Check function and variable names

    The function 'log_metrics' is defined, then overwritten by a dictionary with the same name.
  2. Step 2: Understand consequences of overwriting

    After overwriting, calling 'log_metrics()' would cause an error because it's no longer a function.
  3. Final Answer:

    Function name overwritten by dictionary, causing error on call -> Option D
  4. Quick Check:

    Overwriting function with variable causes call errors [OK]
Quick Trick: Avoid using same name for functions and variables [OK]
Common Mistakes:
  • Ignoring name overwriting issues
  • Thinking print syntax is wrong
  • Believing dictionary syntax is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes