Bird
0
0

Given the code below, what will be the output?

medium📝 Predict Output Q4 of 15
Agentic AI - Real-World Agent Applications
Given the code below, what will be the output?
def research_agent(query):
    data = {'AI': 'Artificial Intelligence', 'ML': 'Machine Learning'}
    return data.get(query, 'Not found')

print(research_agent('ML'))
ANot found
BMachine Learning
CArtificial Intelligence
DError
Step-by-Step Solution
Solution:
  1. Step 1: Understand the function behavior

    The function looks up the query key in the dictionary and returns its value or 'Not found' if missing.
  2. Step 2: Check the input and dictionary

    The query is 'ML', which exists in the dictionary with value 'Machine Learning'.
  3. Final Answer:

    Machine Learning -> Option B
  4. Quick Check:

    Dictionary lookup for 'ML' = 'Machine Learning' [OK]
Quick Trick: Dictionary get returns value or default if key missing [OK]
Common Mistakes:
  • Assuming it returns 'Artificial Intelligence' for 'ML'
  • Expecting an error for missing keys
  • Confusing key with value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes