PCEP Computer Programming and Python Fundamentals Practice Question
Which THREE of the following are valid ways to create a list with elements 1, 2, 3? (Choose Three)
⚠ Common exam trap
The PCEP exam often tests the distinction between list, tuple, and set literals, so candidates mistakenly choose curly-brace or parenthesis syntax as valid list creation methods.
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
✓
[1,2,3]
Option A, [1,2,3], is correct because a list literal enclosed in square brackets directly creates a list with the elements 1, 2, and 3 in order. Option B, list(range(1,4)), is correct because range(1,4) generates the integers 1, 2, 3 (the stop value 4 is exclusive), and wrapping it in the list() constructor materializes them as a list. Option D, [x for x in range(1,4)], is correct because this list comprehension iterates over range(1,4), producing the values 1, 2, 3 and collecting them into a new list. Option C, (1,2,3), is not correct because parentheses create a tuple, not a list, and tuples are immutable and of a different type. Option E, {1,2,3}, is not correct because curly braces create a set, which is unordered and contains no duplicates, so it is not a list.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
[1,2,3]
Why this is correct
A list literal enclosed in square brackets with comma-separated values creates the list directly, producing exactly [1, 2, 3]. This is the most explicit list construction syntax and requires no iteration or conversion, satisfying the requirement for a list containing those three elements.
- ✓
list(range(1,4))
Why this is correct
range(1,4) generates the integers 1, 2 and 3 because the stop value is exclusive, and list() materialises that iterator into a list. The resulting list is exactly [1, 2, 3], matching the required elements without any further processing.
- ✗
(1,2,3)
Why it's wrong here
Parentheses with commas create a tuple, not a list, so this fails the requirement for mutable list syntax. It is tempting because the same three values appear in the correct order, and tuples are a valid sequence type, but square brackets are needed for a list literal.
- ✓
[x for x in range(1,4)]
Why this is correct
The list comprehension iterates over range(1,4), which yields 1, 2 and 3, appending each value to a new list. The result is [1, 2, 3], so this constructs the required list through comprehension syntax rather than a literal or list() conversion.
- ✗
{1,2,3}
Why it's wrong here
Braces create a set, which is unordered and holds unique elements, so {1,2,3} is not a list. It is tempting because the syntax looks similar, but sets would be correct when membership testing or deduplication is required, not when an ordered, indexable sequence is needed.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 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.