Bird
0
0

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:
  1. Step 1: Understand the filtering goal

    The goal is to keep only positive numbers, so the instruction must specify returning positive numbers.
  2. 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.
  3. Final Answer:

    Write a function that returns only positive numbers from the list -> Option A
  4. 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

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes