Back to course room

1DV501 · Introduction to programming · Autumn 2026

Trace a short program

5-minute practice · 3 questions·Original Coursfy practice
1. What is the final value of total?
total = 1
for n in [2, 3, 4]:
    if n % 2 == 0:
        total = total + n
2. Which value does the function return?
def first_even(values):
    for n in values:
        if n % 2 == 0:
            return n
    return -1

first_even([3, 8, 4])
3. The rule says that a score of 10 or higher passes. Which call exposes the bug?
def passes(score):
    return score > 10