Courseiva

PCEP Control Flow, Loops, Lists and Logic Practice Question

A monitoring script checks a list of sensor readings and must stop examining them as soon as a reading above 100 is found, without checking any remaining readings. The readings list contains at least one value above 100. Which loop control approach implements this behavior correctly?

⚠ Common exam trap

The trap here is treating continue as a way to stop the loop, when it only skips the current iteration and keeps iterating.

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

✓

Use break when a reading exceeds 100, so the loop ends immediately and no further readings are checked.

Only break exits a loop immediately when a condition is met. When a reading above 100 is encountered, break ends iteration and control moves past the loop, so no later readings are examined. The other keywords either skip one iteration, do nothing, or run after normal completion.

Answer analysis

Option-by-option breakdown

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

  • ✗

    Use pass when a reading exceeds 100, so the loop silently ignores the condition and finishes normally.

    Why it's wrong here

    pass is a no-op placeholder that does nothing at all; it neither stops nor alters iteration. The loop would still examine every reading to the end, so the early-exit requirement is unmet. pass exists to satisfy syntax where a statement is required, not to control loop flow.

  • ✗

    Use continue when a reading exceeds 100, so the loop skips the rest of that iteration and keeps going.

    Why it's wrong here

    continue only ends the current iteration and proceeds to the next reading, so the loop keeps examining values after the first reading above 100. The requirement is to stop checking entirely, not to skip ahead. Using continue here inspects every remaining element, which contradicts the intended early exit.

  • ✓

    Use break when a reading exceeds 100, so the loop ends immediately and no further readings are checked.

    Why this is correct

    break terminates the innermost enclosing loop at once, so as soon as a reading greater than 100 appears, no subsequent readings are examined. That exactly matches the requirement to stop early. Execution resumes at the first statement after the loop, where the script can act on the detected condition.

  • ✗

    Use else on the for loop, so the loop stops when a reading exceeds 100.

    Why it's wrong here

    A for-else clause does not stop anything; the else block simply runs after the loop finishes without a break. If the loop never breaks, else executes, but it has no power to end iteration early. This construct reports completion, it does not provide early termination for the condition described.

About these practice questions

Courseiva writes every PCEP question from scratch — 482 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or 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.