Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

Which THREE of the following are correct ways to create a list containing the numbers 1, 2, 3? (Choose three.)

⚠ Common exam trap

The PCEP exam often tests the distinction between list literals (`[]`), tuple literals (`()`), and set literals (`{}`), trapping candidates who confuse the syntax for these different data structures.

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

✓

[x for x in range(1,4)]

Option A, `[x for x in range(1,4)]`, is correct because a list comprehension over `range(1,4)` iterates x = 1, 2, 3 (the stop value 4 is exclusive) and builds a list `[1, 2, 3]`. Option C, `list((1, 2, 3))`, is correct because the `list()` constructor converts the tuple `(1, 2, 3)` into a new list containing those same elements. Option D, `[1, 2, 3]`, is correct because it is a direct list literal that already contains the numbers 1, 2, and 3. Option B, `(1, 2, 3)`, does not belong because parentheses create a tuple, not a list. Option E, `{1, 2, 3}`, does not belong because curly braces create a set, which is unordered and 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.

  • ✓

    [x for x in range(1,4)]

    Why this is correct

    range(1,4) yields 1, 2 and 3, stopping before the exclusive upper bound. The comprehension collects each value into a new list, producing [1, 2, 3] with the correct integers in ascending order, satisfying the question's requirement.

  • ✗

    (1, 2, 3)

    Why it's wrong here

    Parentheses create a tuple, an immutable sequence, not a list; the question asks specifically for list creation. It is tempting because the values and order match, but tuples lack list methods such as append, and only square-bracket syntax or list() produces the required mutable list object.

  • ✓

    list((1, 2, 3))

    Why this is correct

    list() accepts any iterable and builds a new list from its elements. Passing the tuple (1, 2, 3) therefore returns [1, 2, 3], converting the tuple's contents into a list rather than copying the tuple itself, which matches the required output.

  • ✓

    [1, 2, 3]

    Why this is correct

    A list literal directly enumerates the elements between square brackets, so `[1, 2, 3]` builds the required list in a single expression. This satisfies the stem's constraint of producing a list containing exactly the numbers 1, 2 and 3, with no conversion or iteration needed.

  • ✗

    {1, 2, 3}

    Why it's wrong here

    Curly braces create a set, which is unordered and rejects duplicates, so it is not a list containing 1, 2, 3. It is tempting because the literal displays the same three numbers, but sets cannot be indexed or appended to, and the question explicitly requires list objects.

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 →

How Courseiva writes practice questions · Editorial policy

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.