PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A developer writes the following code: x = 5; y = x; x = 10. What are the values of x and y after execution?
⚠ Common exam trap
Python Institute often tests the misconception that `y = x` creates a persistent link between variables, leading candidates to incorrectly assume `y` changes when `x` is reassigned.
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 = 10, y = 5
In Python, integers are immutable, and the assignment `y = x` copies the reference to the integer object 5, not the variable itself. When `x = 10` is executed, it binds the name `x` to a new integer object 10, while `y` still references the original object 5. Thus, after execution, `x` is 10 and `y` is 5.
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 = 10, y = 5
Why this is correct
x is reassigned to 10, y still holds the original 5
- ✗
x = 5, y = 10
Why it's wrong here
x is reassigned to 10, so x is 10
- ✗
x = 5, y = 5
Why it's wrong here
x is reassigned to 10
- ✗
x = 10, y = 10
Why it's wrong here
y is not a reference; it copies the value
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 498 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 →
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.