Question 297 of 498
PCEP Control Flow, Loops, Lists and Logic Practice Question
Exhibit
data = [1, 2, 3, 4, 5]
result = []
for x in data:
if x % 2 == 0:
result.append(x * 2)
else:
result.append(x * 3)
print(result[2])What is the output of the following code?
numbers = [1, 2, 3, 4, 5] total = 0
for i in numbers:
if i % 2 == 0:continue total += i
print(total)
⚠ Common exam trap
Python Institute often tests the `continue` statement by embedding it inside a conditional that filters out specific values, leading candidates to mistakenly sum all elements or incorrectly include the skipped values.
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
✓
9
The exhibit shows code that iterates over the list [1, 2, 3, 4, 5] and uses `if i % 2 == 0: continue` to skip even numbers. Only odd numbers (1, 3, 5) are summed, giving 1 + 3 + 5 = 9. Therefore, option D is correct.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
10
Why it's wrong here
Not present; 10 would be 5*2.
- ✗
8
Why it's wrong here
8 is at index 3.
- ✗
6
Why it's wrong here
Incorrect; 3*2=6 but actual is 9.
- ✓
9
Why this is correct
Correct; index 2 is 9.
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 →
Same concept, more angles
1 more way this is tested on PCEP
These questions test the same concept from different angles. Work through them to make sure you can recognise it however the exam phrases it.
Variation 1. A developer is writing a function that takes a list of numbers and returns the sum of all even numbers. Which two code snippets correctly implement this function? (Select two.)
medium- A.def sum_even(nums): return [n for n in nums if n%2==0]
- B.def sum_even(nums): total=0; for i in range(len(nums)): if nums[i]%2==0: total+=nums[i]*2; return total
- ✓ C.def sum_even(nums): total=0; for n in nums: if n%2==0: total+=n; return total
- D.def sum_even(nums): total=0; for n in nums: if n%2==1: total+=n; return total
- ✓ E.def sum_even(nums): return sum(n for n in nums if n%2==0)
Why C: It initializes a total variable to 0, iterates over each number in the list, checks if it is even using the modulo operator (n % 2 == 0), and adds the number to the total. This correctly accumulates the sum of all even numbers and returns the final total.
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.