Courseiva
Data Types, Variables, Basic I/O and OperatorsmediumMultiple ChoiceObjective-mapped

PCEP Practice Question: Data Types, Variables, Basic I/O and Operators

Exhibit

x = input("Enter x: ")
y = input("Enter y: ")
print(x + y)

Refer to the exhibit. If the user enters 5 and 3, what is the output?

⚠ Common exam trap

Python Institute often tests the misconception that `input()` returns a numeric type when digits are entered, leading candidates to expect arithmetic addition instead of string concatenation.

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

53

In Python, the `input()` function always returns a string. When the user enters 5 and 3, the `+` operator concatenates the two strings '5' and '3', producing the string '53'. Option D is correct because no numeric conversion is performed.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • 8

    Why it's wrong here

    Would happen if x and y were numeric.

  • 5 3

    Why it's wrong here

    No space is added.

  • TypeError

    Why it's wrong here

    No error, strings can be concatenated.

  • 53

    Why this is correct

    String concatenation of '5' and '3'.

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 →

How Courseiva writes practice questions · Editorial policy

Same concept, more angles

4 more ways 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 when the user enters 25?

easy
  • A.Error
  • B.2525
  • C.25
  • D.50

Why B: When the user enters 25, the input() function returns the string "25". The print() function then concatenates the string "25" with itself using the + operator, resulting in "2525". This is because the + operator performs string concatenation when both operands are strings, not numeric addition.

Variation 2. A developer writes: num = input('Enter a number: '); result = num * 2; print(result). If the user enters 5, what is the output?

medium
  • A.Error: cannot multiply string by int
  • B.10
  • C.'5' * 2
  • D.55

Why D: The `input()` function always returns a string. When the user enters '5', `num` is the string '5', not the integer 5. The `*` operator on a string performs repetition, so `'5' * 2` produces '55', which is printed as 55.

Variation 3. Consider the following code: x = input('Enter a number: ') print(x + x) A user enters 5 at the prompt. What is printed?

easy
  • A.55
  • B.10
  • C.5
  • D.25

Why A: 55 because Python's input() function returns a string. When the user enters 5, it is stored as the string '5'. If the code then uses the + operator to concatenate this string with itself (e.g., print(input() + input()) or print(x + x)), the result is '55', not numeric addition.

Variation 4. A user enters '42' at an input prompt. After executing x = input(), what is the type of x?

easy
  • A.float
  • B.str
  • C.bool
  • D.int

Why B: The `input()` function in Python always returns the user's input as a string, regardless of whether the input looks like a number. When the user enters '42', it is captured as the string '42', so the type of `x` is `str`. This is because `input()` does not perform any implicit type conversion.

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.