PCEP Control Flow, Loops, Lists and Logic Practice Question
A developer is auditing loop constructs in a Python script. Which TWO statements about `break`, `continue`, `else`, and `range` are correct in Python? (Choose two.)
⚠ Common exam trap
The trap here is assuming a loop's `else` runs regardless of how the loop ends, when a `break` actually suppresses it.
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
✓
`continue` skips the rest of the current iteration and immediately re-evaluates the loop condition or fetches the next item.
The `else` clause of a loop runs only on normal exhaustion, not after a `break`, which supports search idioms. `continue` ends the current iteration and moves to the next, re-evaluating or advancing as appropriate. The other statements misdescribe `break` as iteration-skipping, give `range` an inclusive upper bound, and claim `while` always runs once, all of which are incorrect for Python.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
`break` exits only the current iteration and resumes with the next item.
Why it's wrong here
This misstates `break`, which exits the innermost enclosing loop entirely and resumes execution after the loop. Skipping just one iteration is the job of `continue`. Confusing the two leads to code that stops early when it should keep scanning, or keeps scanning after the target has already been found.
- ✗
A `while` loop always executes its body at least once, even if the condition is initially false.
Why it's wrong here
A `while` loop tests its condition before each iteration, so if the condition is false on entry the body never runs. Only a `do-while` style construct, which Python lacks natively, guarantees at least one execution. This statement describes behaviour that does not exist for `while` in Python.
- ✗
`range(5)` produces the list `[0, 1, 2, 3, 4, 5]` when printed.
Why it's wrong here
`range(5)` stops before the stop value, yielding `0` through `4`, not `5`. Printing a range object also shows something like `range(0, 5)`, not a list, unless it is converted. The off-by-one confusion here is a frequent source of bugs when sizing loops or indexing sequences.
- ✓
`continue` skips the rest of the current iteration and immediately re-evaluates the loop condition or fetches the next item.
Why this is correct
This correctly describes `continue`: it abandons the remaining statements in the current iteration and proceeds to the next one, re-checking the condition in a `while` loop or advancing the iterator in a `for` loop. It is often used to skip unwanted values without nesting the body inside a large `if` block, keeping the code flatter.
- ✓
A loop's `else` clause executes only if the loop finishes without hitting a `break`.
Why this is correct
This is accurate: the optional `else` block on `for` and `while` runs when the loop terminates by exhausting its iterable or failing its condition, but not when it is exited by `break`. That makes it useful for search patterns, letting you distinguish a full scan from an early exit without extra flag variables, which is a common source of confusion.
Go deeper
Related to this question
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 →
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.