PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A programmer writes: x = 5; y = "10"; z = x + y. What will happen?
⚠ Common exam trap
Python Institute often tests the misconception that Python will automatically convert types to make the operation work, either by treating the integer as a string (concatenation) or the string as a number (addition), when in fact Python raises a TypeError for mixed-type '+' operations.
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
✓
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Python does not implicitly convert between incompatible types for the '+' operator. When an integer (int) and a string (str) are used with '+', Python raises a TypeError, as it cannot decide whether to perform arithmetic addition or string concatenation without explicit conversion.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Prints error but continues execution
Why it's wrong here
An unhandled TypeError terminates the script immediately; execution does not resume after the failed addition. It is tempting because try/except blocks do let programs continue after caught exceptions, but this snippet contains no handler, so the traceback halts the interpreter.
- ✗
Prints 510
Why it's wrong here
Would only happen if both were strings.
- ✓
TypeError: unsupported operand type(s) for +: 'int' and 'str'
Why this is correct
Python binds the + operator to the operand types at runtime, and no implicit coercion exists between int and str. Adding 5 to "10" therefore raises TypeError, satisfying the stem's requirement that mixed-type addition without explicit conversion fails rather than silently concatenating or coercing.
- ✗
Prints 15
Why it's wrong here
Python raises a TypeError because it refuses implicit concatenation of int and str, so nothing prints. The option tempts those expecting JavaScript-style coercion, where "10" would be converted and 15 produced; Python requires explicit int(y) or str(x) conversion.
Go deeper
Related to this question
About these practice questions
One of 482 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.