PCEP Control Flow, Loops, Lists and Logic Practice Question
A programmer is reviewing code that uses loops and conditional statements. Which TWO of the following statements about Python control flow are correct? (Choose two.)
⚠ Common exam trap
The trap here is mixing up continue and break, or assuming that while loops always execute at least once as in some other languages.
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
✓
An if statement can be nested inside a for loop, and a for loop can be nested inside an if statement.
The two correct statements are that a for loop's else runs only without a break, and that control structures can be nested arbitrarily. These reflect Python's actual semantics. The other statements mischaracterize continue, break, and while loop behavior, each of which is well-defined and different from the described behavior.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
An if statement can be nested inside a for loop, and a for loop can be nested inside an if statement.
Why this is correct
Python allows arbitrary nesting of control structures. An if can appear inside a for body, and a for can appear inside an if body, as long as indentation is correct. This flexibility enables complex logic, such as filtering items with if and then iterating over a subset with for, or vice versa.
- ✗
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 checks its condition before each iteration, so if the condition is false initially, the body never executes. A loop that always runs at least once would be a do-while loop, which Python does not have natively. This statement describes a common misconception from other languages.
- ✗
The break statement can be used outside a loop to terminate the program.
Why it's wrong here
break is only valid inside a loop (for or while). Using it outside a loop raises a SyntaxError. To terminate a program, one would use sys.exit() or raise SystemExit. The break statement is strictly for early loop termination and cannot be used as a general program exit mechanism.
- ✓
The else clause of a for loop executes only if the loop completes without encountering a break.
Why this is correct
Python's for and while loops can have an else clause that runs when the loop finishes normally, i.e., without a break. If a break terminates the loop, the else block is skipped. This behavior is useful for search loops where you want to run code only if the item was not found, and it is a distinctive feature of Python.
- ✗
The continue statement exits the current loop entirely and resumes execution after the loop.
Why it's wrong here
continue does not exit the loop; it skips the remaining statements in the current iteration and proceeds to the next iteration. Exiting the loop entirely is the role of break. Confusing continue with break leads to incorrect control flow, such as skipping only one element instead of stopping the loop.
Go deeper
Related to this question
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 →
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.