Comprehension and filtering semantics
Problem
Implement even_squares(xs), returning the squares of even values in input order using a single list comprehension.
Starter code
def even_squares(xs):
passReveal answer or reference solution
def even_squares(xs):
return [x * x for x in xs if x % 2 == 0]Public tests
even_squares([3, -2, 0, 5, 4])→[4, 0, 16]even_squares([1, 3])→[]
Local history
Loading attempts saved in this browser…
Use with your agent
Share this URL and your attempt. Ask the agent to start with a clarifying question or the smallest useful hint.
Tutor me on https://mlprep.iwase.dev/programming/control-flow/original-py-comprehensions/. If window.mlPrepAgent is available, read attempts for item original-py-comprehensions before tutoring. Inspect my attempt, keep the item ID, and do not reveal the full answer first. After a real attempt, append its record and read it back.