PCEP Control Flow, Loops, Lists and Logic Practice Question
A programmer is writing a script to process a list of sensor readings. The script should stop processing as soon as a reading of 0 is encountered. Which statement should be placed inside the loop to achieve this?
⚠ Common exam trap
Test-takers frequently confuse `break` with `continue`; `break` exits the loop entirely, while `continue` 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
✓
break
To stop a loop immediately when a condition is met, the `break` statement is used. It transfers control to the statement immediately following the loop. The `continue` statement would only skip the current iteration, while `pass` does nothing and `exit` is not a valid loop control statement.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
exit
Why it's wrong here
`exit` is not a Python keyword or built-in function for loop control. It is sometimes available as `sys.exit()` to terminate the entire program, but it is not used to break out of a loop. Using `exit` would cause a `NameError` because it is not defined by default.
- ✓
break
Why this is correct
The `break` statement immediately terminates the innermost enclosing loop. When a sensor reading of 0 is detected, using `break` will exit the loop entirely, preventing further processing of remaining readings. This matches the requirement to stop processing as soon as the condition is met.
- ✗
pass
Why it's wrong here
`pass` is a null statement that does nothing. It is used as a placeholder where code is syntactically required but no action is needed. Using `pass` would not stop the loop; it would allow the loop to continue processing all readings, including the 0.
- ✗
continue
Why it's wrong here
The `continue` statement skips the rest of the current iteration and moves to the next iteration. It does not stop the loop; it would simply skip processing the 0 reading and continue with subsequent readings, which does not meet the requirement to stop processing entirely.
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.