Reference solution
The shape we check against. Any implementation that passes the assertions is valid — this one favours clarity.
def sum_evens(nums):
return sum(n for n in nums if n % 2 == 0)
Write sum_evens(nums) that returns the sum of all even numbers in the list nums. Return 0 for an empty list.
hint ladder
Inspect a chained expression (df.query(…).groupby(…).agg(…)) to see the shape and preview after each step.
Run your code to see its output, or check your solution to grade it.
Reference solution
The shape we check against. Any implementation that passes the assertions is valid — this one favours clarity.
def sum_evens(nums):
return sum(n for n in nums if n % 2 == 0)
Code is blurred until you solve this problem — the reasoning stays readable.