Courseiva

PCEP Control Flow, Loops, Lists and Logic Practice Question

A developer is writing a Python script to process a list of integers representing inventory counts. The developer needs to iterate over the list and, for each element, perform an action, but also needs to be able to terminate the entire loop early when a sentinel value (0) is encountered. Which two statements about loop control in Python are correct? (Choose two.)

⚠ Common exam trap

It's easy for candidates to confuse break with return or assuming that continue terminates the loop, when it only skips the current iteration.

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

✓

The continue statement skips the rest of the current iteration and proceeds to the next iteration of the loop.

The break statement exits the innermost loop immediately, which is suitable for stopping on a sentinel value. The continue statement skips to the next iteration without terminating the loop. These two control statements are fundamental for managing loop execution and are distinct from return, which exits a function.

Answer analysis

Option-by-option breakdown

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

  • ✗

    The continue statement terminates the loop and resumes execution after the loop.

    Why it's wrong here

    The continue statement does not terminate the loop; it only skips the remainder of the current iteration. The loop then continues with the next item. Termination is handled by break. Using continue when the intention is to stop processing entirely would lead to unintended extra iterations and potentially incorrect results.

  • ✓

    The continue statement skips the rest of the current iteration and proceeds to the next iteration of the loop.

    Why this is correct

    The continue statement abandons the remaining statements in the current loop body and jumps to the next iteration. It does not terminate the loop. In the inventory scenario, continue could be used to skip processing for a particular value while still examining subsequent elements, which is different from early termination.

  • ✓

    The break statement immediately exits the innermost enclosing loop.

    Why this is correct

    The break statement terminates the nearest enclosing for or while loop and transfers control to the first statement after the loop. In nested loops, it only exits the innermost loop, not all loops. This is exactly what the developer needs to stop processing when a sentinel value is found, without continuing to the remaining elements.

  • ✗

    A for loop in Python automatically stops when it encounters a None value in the sequence.

    Why it's wrong here

    Python's for loop iterates over all elements of the iterable, regardless of their value. None is a valid element and does not cause the loop to stop. The developer must explicitly check for a sentinel value and use break if early termination is desired. Relying on automatic stopping would be incorrect.

  • ✗

    The break statement can be used outside a loop to exit a function early.

    Why it's wrong here

    The break statement is only valid inside a for or while loop. Using it outside a loop raises a SyntaxError. To exit a function early, the developer should use return. Confusing break with return is a common mistake, but they serve different purposes and have different syntactic requirements.

About these practice questions

One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.