Question 454 of 498
PCEP Control Flow, Loops, Lists and Logic Practice Question
Which code correctly and efficiently sums only positive numbers from a list?
⚠ Common exam trap
Python Institute often tests the distinction between `break` and `continue`, and the trap here is that candidates mistakenly use `break` (thinking it skips one item) or add unnecessary `else` branches, when `continue` is the correct way to skip an iteration without terminating the loop.
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
✓
for num in numbers: if num <= 0: continue total += num
It uses `continue` to skip non-positive numbers and then unconditionally adds the remaining numbers to `total`. This is both efficient (no unnecessary `else` branch) and correct: it sums only positive numbers without breaking the loop prematurely or adding zero/negative values.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
for num in numbers: if num > 0: total += num else: break
Why it's wrong here
Break stops the loop on first non-positive.
- ✗
for num in numbers: if num <= 0: pass else: total += num
Why it's wrong here
Works but pass is redundant; not efficient.
- ✗
for num in numbers: if num > 0: total += num else: continue
Why it's wrong here
Works but else continue is unnecessary.
- ✓
for num in numbers: if num <= 0: continue total += num
Why this is correct
Correct and efficient; skips non-positive.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Last reviewed: Jun 30, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.