PCEP Computer Programming and Python Fundamentals Practice Question
A program uses a for loop to double each element in a list: numbers = [1, 2, 3, 4, 5]; for num in numbers: num = num * 2. After execution, numbers remains unchanged. Why?
⚠ Common exam trap
The PCEP exam often tests the misconception that the loop variable is a mutable alias for the list element, leading candidates to believe reassigning it will update the list, when in fact it only rebinds the local variable.
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
✓
Reassigning num does not modify the original list element; you need to modify via index.
In Python, the loop variable `num` is a reference to each element in the list, but reassigning `num` (e.g., `num = num * 2`) merely rebinds the local variable to a new integer object; it does not modify the original list element. To change the list in place, you must access elements by their index, such as `numbers[i] = numbers[i] * 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.
- ✓
Reassigning num does not modify the original list element; you need to modify via index.
Why this is correct
Correct: num = num * 2 just rebinds num, not the list.
- ✗
The assignment creates a new list, leaving the original unchanged.
Why it's wrong here
No new list created; just reassigns variable.
- ✗
Lists are immutable; their elements cannot be changed.
Why it's wrong here
Lists are mutable; elements can be changed via indexing.
- ✗
The variable num is a copy of the list element.
Why it's wrong here
In Python, all variables are references; but reassigning does not affect list.
Go deeper
Related to this question
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 →
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.