Question 108 of 498
PCEP Computer Programming and Python Fundamentals Practice Question
A Python script contains the following code:
x = [1, 2, 3] y = x y.append(4) z = x.copy() z.append(5)
After execution, which TWO of the following statements are true? (Choose two.)
⚠ Common exam trap
The PCEP exam often tests the distinction between reference assignment and copying; the trap here is that candidates mistakenly think `y = x` creates a new list, leading them to believe `x` remains unchanged after `y.append(4)`.
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 is equal to [1, 2, 3, 4]
`y = x` creates a reference to the same list object, not a copy. When `y.append(4)` is called, it modifies the shared list, so `x` becomes `[1, 2, 3, 4]`. This demonstrates that assignment in Python does not copy objects; it binds a new name to the existing object.
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 and y refer to different list objects
Why it's wrong here
x and y refer to the same list object.
- ✗
x is equal to [1, 2, 3]
Why it's wrong here
x was modified via y.
- ✓
x is equal to [1, 2, 3, 4]
Why this is correct
y is a reference to x; appending to y modifies x.
- ✗
x is equal to [1, 2, 3, 4, 5]
Why it's wrong here
z is a copy, appending to z does not affect x.
- ✓
z is equal to [1, 2, 3, 5]
Why this is correct
z is a copy of the original x, then 5 appended.
About these practice questions
Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →
Same concept, more angles
1 more way 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. What is the output of the following code? x = [1, 2, 3]; y = x; y.append(4); print(x)
hard- ✓ A.[1,2,3,4]
- B.Error
- C.[4]
- D.[1,2,3]
Why A: In Python, variables hold references to objects, not copies. When `y = x` is executed, both `x` and `y` point to the same list object in memory. The `y.append(4)` method modifies that shared list in-place, so printing `x` reflects the change and outputs `[1, 2, 3, 4]`.
Last reviewed: Jul 4, 2026
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.
Question Discussion
Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.
Sign in to join the discussion.