Question 434 of 498
PCEP Computer Programming and Python Fundamentals Practice Question
A junior developer writes the following code to swap two variables: a = 5; b = 10; a = b; b = a. When they print a and b, what is the output?
⚠ Common exam trap
The PCEP exam often tests the misconception that `b = a` after `a = b` somehow retrieves the original value of `a`, when in fact the original value is already overwritten.
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
✓
10 10
After `a = b`, both variables hold the value 10. Then `b = a` assigns the current value of `a` (which is now 10) to `b`, so both remain 10. The original value of `a` (5) is lost because it was overwritten before being saved.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
10 10
Why this is correct
After a = b, a becomes 10. Then b = a sets b to 10, so both are 10.
- ✗
5 5
Why it's wrong here
This would only happen if both assignments were reversed, not the case here.
- ✗
5 10
Why it's wrong here
This would be the output if the swap were done correctly, but the code does not achieve a proper swap.
- ✗
10 5
Why it's wrong here
This would require a temporary variable or tuple unpacking; the given code does not produce this result.
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 →
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.