PCEP Computer Programming and Python Fundamentals Practice Question
A developer wants to create a list of even numbers from 0 to 10 inclusive. Which code snippet will correctly produce [0, 2, 4, 6, 8, 10]?
⚠ Common exam trap
The PCEP exam often tests whether candidates recognize that multiple approaches can produce the same correct result, and the trap here is that a student might dismiss Option C because it uses multiplication instead of a step or filter, not realizing it still yields the exact target list.
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
✓
All of the above
All three code snippets produce the list [0, 2, 4, 6, 8, 10]. Option A uses the built-in `range()` function with a step of 2, starting at 0 and stopping before 11. Option B is a list comprehension that iterates over range(11) and filters numbers where the remainder when divided by 2 is 0. Option C multiplies each integer from 0 to 5 by 2, yielding the same even numbers. Therefore, 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.
- ✗
list(range(0,11,2))
Why it's wrong here
This creates a list with step 2.
- ✗
[x for x in range(11) if x%2==0]
Why it's wrong here
This filters even numbers from 0 to 10.
- ✗
[x*2 for x in range(6)]
Why it's wrong here
This produces [0,2,4,6,8,10] as well.
- ✓
All of the above
Why this is correct
All three snippets produce the same list.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 498 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 by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
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.