PCEP Control Flow, Loops, Lists and Logic Practice Question
Which THREE of the following are valid ways to create a list with elements 10, 20, 30?
⚠ Common exam trap
In multi-select questions, carefully evaluate each option against the stem without reading in extra constraints. The question simply asks for valid ways to create a specific list; do not assume that a literal assignment is excluded unless explicitly stated. Be cautious about the number of correct answers: ensure you select all that apply, especially when the stem specifies a count.
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
✓
my_list = [x for x in (10,20,30)]
Options A, B, and E are all valid ways to create a list with the elements 10, 20, 30. Option A uses a list comprehension to iterate over a tuple and produce the list. Option B uses the list() constructor with a tuple as the single iterable argument. Option E is the most direct way: a list literal. Options C and D are invalid: C because list() requires a single iterable, not multiple positional arguments; D because Python list elements must be separated by commas, not semicolons.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
my_list = [x for x in (10,20,30)]
Why this is correct
Correct. List comprehension creates a list from the tuple elements.
- ✓
my_list = list((10, 20, 30))
Why this is correct
Correct. The list() constructor with a tuple as argument creates a list.
- ✗
my_list = list(10, 20, 30)
Why it's wrong here
Incorrect. list() takes one iterable, not multiple arguments.
- ✗
my_list = [10; 20; 30]
Why it's wrong here
Incorrect. List elements must be separated by commas, not semicolons.
- ✓
my_list = [10, 20, 30]
Why this is correct
Incorrect. Although a literal list works, this question asks for ways to create a list from a given tuple, so direct literal assignment is not considered a valid method here.
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.