Courseiva
Functions, Tuples, Dictionaries and ExceptionsmediumMultiple SelectObjective-mapped

PCEP Practice Question: Functions, Tuples, Dictionaries and Exceptions

Which TWO of the following are valid ways to create a tuple containing the elements 1 and 2? (Select two.)

⚠ Common exam trap

Python Institute often tests the misconception that parentheses alone create a tuple, leading candidates to select `(1)` as a valid tuple, when in fact a trailing comma is required for a single-element tuple (e.g., `(1,)`).

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

tuple([1, 2])

`tuple([1, 2])` calls the `tuple()` constructor with a list `[1, 2]` as an argument, which converts the list into a tuple `(1, 2)`. Option E is correct because `(1, 2)` is the literal syntax for a tuple containing the elements 1 and 2.

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)

    Why it's wrong here

    Incorrect; this is an integer, not a tuple.

  • [1, 2]

    Why it's wrong here

    Incorrect; this is a list.

  • int(1)

    Why it's wrong here

    Incorrect; integer.

  • tuple([1, 2])

    Why this is correct

    Correct; converts list to tuple.

  • (1, 2)

    Why this is correct

    Correct; literal tuple.

About these practice questions

One of 498 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

2 more ways 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. Which of the following correctly creates a tuple with a single element 5?

easy
  • A.t = (5,)
  • B.t = (5)
  • C.t = (5)
  • D.t = (5, 5)

Why A: In Python, a tuple with a single element requires a trailing comma after the element. Without the comma, parentheses are treated as grouping operators for expression evaluation, not as a tuple literal. Thus, `t = (5,)` creates a tuple containing the integer 5.

Variation 2. Which THREE of the following are valid ways to create a list in Python?

easy
  • A.list((1, 2, 3))
  • B.[x for x in range(3)]
  • C.[1, 2, 3]
  • D.(1, 2, 3)
  • E.{1, 2, 3}

Why A: The `list()` constructor can take an iterable, such as a tuple, and convert it into a new list. `list((1, 2, 3))` explicitly creates a list `[1, 2, 3]` from the tuple `(1, 2, 3)`. This is a standard and valid way to create a list in Python.

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.