Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A developer writes a loop to find the first even number in a list:

numbers = [3, 5, 8, 10]

for n in numbers:
    if n % 2 == 0:
        print(n)

break else:

print('No even number')

What is printed?

⚠ Common exam trap

The trap here is reading the loop's else as an ordinary conditional else, when it actually runs only when no break occurred.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

8

A for loop's else clause executes only if the loop finishes without encountering break. Here the loop breaks when the first even value 8 is found, so the else is bypassed and only 8 is printed. The modulo test n % 2 == 0 correctly identifies even numbers.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    8

    Why this is correct

    The loop checks each number with the modulo operator. The first two values, 3 and 5, are odd, so the condition fails. When n becomes 8, n % 2 equals 0, so the value is printed and break exits the loop immediately. Because the loop was broken, the else clause is skipped, leaving 8 as the only output.

  • ✗

    No even number

    Why it's wrong here

    The else clause attached to a for loop runs only when the loop completes without hitting break. Since the list contains even values and the loop breaks at 8, the else block never executes. Printing this message would require every element to be odd, which is not the case for this list.

  • ✗

    8 10

    Why it's wrong here

    The break statement terminates the loop as soon as an even number is found. After printing 8, control jumps out of the loop, so 10 is never examined. If the break were removed, both even values would print, but its presence ensures only the first match appears before the loop ends.

  • ✗

    8 No even number

    Why it's wrong here

    The for-else construct makes the else and break mutually exclusive: once break runs, the else is skipped entirely. Printing both would mean the loop both broke and exhausted normally, which cannot happen. The code therefore outputs only the matched value, not the fallback message as well.

About these practice questions

This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written and reviewed by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

Last reviewed September 2026 · checked against the official Python Institute exam blueprint

This PCEP practice question is part of Courseiva's free Python Institute certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the PCEP exam.