Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

A function is supposed to modify a list passed as argument by appending an element. However, after calling the function, the original list remains unchanged. Which is the most likely cause?

⚠ Common exam trap

The PCEP exam often tests the distinction between mutating an object in-place versus reassigning the parameter name, exploiting the common misconception that reassigning a parameter inside a function will affect the original argument.

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 function reassigns the list parameter instead of mutating it.

In Python, when a list is passed to a function, the parameter refers to the same list object. If the function reassigns the parameter (e.g., `lst = [1, 2, 3]`), it only changes the local reference, not the original list. To modify the original list, the function must mutate it in-place using methods like `append()` or `extend()`, not reassign the parameter.

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 list is immutable.

    Why it's wrong here

    Python lists are mutable, so immutability cannot explain the unchanged original. The option is tempting because immutable types such as tuples and strings do resist in-place modification, but a list supports append directly. The real cause is that the function rebinds a new list rather than mutating the passed object.

  • ✗

    The list is a tuple.

    Why it's wrong here

    A tuple cannot be passed where a list is expected and has no append method, so calling append would raise an AttributeError rather than silently leaving the original unchanged. It is tempting because tuples are immutable, but the stem describes a list argument, so the tuple explanation does not fit the observed behaviour.

  • ✗

    The function uses a local variable that shadows the global list.

    Why it's wrong here

    A local variable shadowing a global name would not affect a list passed as an argument; the parameter still references the caller's list, and append would mutate it. It is tempting because shadowing causes confusing scope bugs, but the actual cause is rebinding the parameter to a new list instead of mutating in place.

  • ✓

    The function reassigns the list parameter instead of mutating it.

    Why this is correct

    Reassigning the parameter rebinds the local name to a new list object, so the caller's reference still points to the original, unmodified list. Appending mutates in place and would persist; assignment breaks that link, satisfying the stem's requirement that the original list stays unchanged.

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.