Which instruction will most likely produce the correct function?
hard📝 Application Q15 of 15
Agentic AI - Real-World Agent Applications
You want a code generation agent to create a Python function that filters out all negative numbers from a list and returns the positive numbers only. Which instruction will most likely produce the correct function?
A<code>Write a function that returns only positive numbers from the list</code>
B<code>Write a function that returns all numbers less than zero from the list</code>
C<code>Write a function that returns the sum of all numbers in the list</code>
D<code>Write a function that returns the list sorted in descending order</code>
Step-by-Step Solution
Solution:
Step 1: Understand the filtering goal
The goal is to keep only positive numbers, so the instruction must specify returning positive numbers.
Step 2: Evaluate each instruction
Write a function that returns only positive numbers from the list correctly asks for a function returning only positive numbers. Others do different tasks.
Final Answer:
Write a function that returns only positive numbers from the list -> Option A
Quick Check:
Filter positive numbers = Write a function that returns only positive numbers from the list [OK]
Quick Trick:Look for 'returns only positive numbers' in instruction [OK]
Common Mistakes:
Choosing instructions that filter negatives instead
Confusing filtering with summing or sorting
Ignoring the word 'positive' in instruction
Master "Real-World Agent Applications" in Agentic AI
9 interactive learning modes - each teaches the same concept differently