PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A junior developer writes: result = input("Enter first: ") + input("Enter second: ") and then prints result. When entering 5 and 3, the output is '53'. Which explanation is correct?
⚠ Common exam trap
Watch out — candidates often assume `input()` returns a numeric type when numbers are entered, or that Python's dynamic typing will automatically convert strings to numbers for addition, leading them to choose option B or C instead of recognizing the default string behavior.
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
✓
The input() function returns a string, so + performs string concatenation.
The `input()` function in Python always returns a string, regardless of what the user types. When the `+` operator is used with two strings, it performs concatenation, not arithmetic addition. Thus, entering 5 and 3 results in the strings '5' and '3' being joined to produce '53'.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The code uses the wrong operator; it should use the & operator for addition.
Why it's wrong here
The & operator is for bitwise AND, not addition.
- ✗
The input() function automatically selects the correct type, but the + operator is overloaded to concatenate.
Why it's wrong here
input() does not automatically select type; it always returns a string.
- ✗
Python automatically converts strings to numbers when using +, but only for integers.
Why it's wrong here
Python does not automatically convert strings to numbers.
- ✓
The input() function returns a string, so + performs string concatenation.
Why this is correct
input() always returns a string, so + concatenates.
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.