Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A program uses a variable named 'list' that shadows the built-in list type. Later, the code tries to create a new list using list([1,2,3]) but gets a TypeError. What is the most likely cause?

⚠ Common exam trap

Python Institute often tests the concept of name shadowing, where candidates mistakenly think the error is due to invalid arguments or missing imports, rather than recognizing that reassigning a built-in name makes it non-callable.

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

✓

The variable 'list' is now an integer or other non-callable type.

When a variable named 'list' is assigned a value (e.g., an integer), it shadows the built-in `list` type in the current scope. Later, calling `list([1,2,3])` attempts to call the variable `list` as a function, but since it now holds a non-callable object (like an integer), Python raises a TypeError. This is a classic name-shadowing issue in Python.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    The argument [1,2,3] is invalid because it contains integers.

    Why it's wrong here

    Integers are perfectly valid list elements, so the argument is not the problem. Rebinding 'list' to another object replaces the built-in, and calling that object raises TypeError because it is not callable. The option tempts by blaming the data rather than the shadowed name.

  • ✓

    The variable 'list' is now an integer or other non-callable type.

    Why this is correct

    Rebinding the name 'list' to a non-callable value, such as an integer, means list([1,2,3]) attempts to call that object, raising TypeError. The built-in list type is shadowed in that scope, so the original constructor is no longer reachable via that name.

  • ✗

    The list constructor expects a tuple, not a list.

    Why it's wrong here

    The list constructor accepts any iterable, including a list, so the argument type is not the issue. Shadowing the built-in name 'list' with a non-callable object causes the TypeError when the call is attempted. The option tempts by misremembering constructor signatures rather than recognising name shadowing.

  • ✗

    The code is missing an import for the list type.

    Why it's wrong here

    The list type is a built-in, always available without any import, so a missing import cannot cause the error. Rebinding the name 'list' to a non-callable object shadows the built-in and triggers TypeError on invocation. The option tempts because imports are commonly required for other types.

About these practice questions

One of 482 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

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.