PCEP Control Flow, Loops, Lists and Logic Practice Question
A Python developer is writing a script that processes a list of temperatures in a loop. Inside the loop, a conditional block handles sub-zero readings by appending a warning to a report. The developer notices that the loop body is executing even for temperatures that are not sub-zero. Which statement about Python's `if`/`elif`/`else` structure explains why a block guarded by `if temp < 0:` should not execute for a temperature of 5?
⚠ Common exam trap
The trap here is assuming an `if` block can be triggered by side effects like variable reassignment or sibling clauses, when only the truth value of its own condition controls execution.
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 `if` block executes only when its condition evaluates to a truthy value; since `5 < 0` is False, the block is skipped.
Conditional blocks in Python execute based on the truth value of their condition, evaluated before the block runs. Because `5 < 0` is False, the guarded block is skipped and control moves on. The other statements misdescribe evaluation order, trigger conditions, or dependencies among sibling clauses, none of which match Python's top-down conditional evaluation model.
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 `if` block executes whenever the loop variable is reassigned, regardless of the condition's truth value.
Why it's wrong here
Reassigning a variable does not trigger block execution; only the condition's truth value determines whether the indented suite runs. The loop assigns each temperature to the variable, but the `if` suite runs solely based on the comparison result. This option misstates how Python controls conditional blocks inside loops.
- ✗
The `if` block executes only if a previous `elif` condition was also False, making it dependent on sibling clauses.
Why it's wrong here
An `if` clause is evaluated independently first; it does not depend on any `elif` or `else` siblings. Those clauses are only considered when the preceding conditions are false. This option misrepresents the top-down evaluation order of the `if`/`elif`/`else` chain and would wrongly suggest the block's execution hinges on later clauses.
- ✗
The `if` block executes for every iteration because Python evaluates conditions after running the block once.
Why it's wrong here
Python evaluates the condition before executing the block, not after. Conditions are checked at the start of each encounter with the `if` statement, and the block runs only when the result is truthy. This option reverses the evaluation order and would imply every loop iteration triggers the block, which contradicts observed behavior.
- ✓
The `if` block executes only when its condition evaluates to a truthy value; since `5 < 0` is False, the block is skipped.
Why this is correct
Python evaluates the condition `temp < 0` and, for a temperature of 5, produces the boolean False. A false condition causes the indented block under `if` to be skipped entirely, and control passes to any `elif` or `else` clause or to the next statement after the structure. This is the fundamental rule governing conditional execution.
Go deeper
Related to this question
About these practice questions
This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam 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.