PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Exhibit
Refer to the exhibit.
name = input('Enter name: ')
age = input('Enter age: ')
print(name + ' is ' + age + ' years old.')A user enters 'Alice' for name and '30' for age. What is the output?
⚠ Common exam trap
The trap here is that candidates mistakenly think `input()` returns an integer for numeric input, leading them to expect a `TypeError` when concatenating a string with an integer, but in Python `input()` always returns a string, so no error occurs.
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
✓
Alice is 30 years old.
The code `print(name + ' is ' + age + ' years old.')` concatenates the string `'Alice '`, the string `' is '`, the string `'30'`, and the string `' years old.'` using the `+` operator. In Python, the `+` operator performs string concatenation when both operands are strings, and since `input()` always returns a string, both `name` and `age` are strings, so no type error occurs. The output is exactly `Alice is 30 years old.` including the period at the end.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
Alice is 30 years old.
Why this is correct
Correct concatenation.
- ✗
Alice is 30 years old
Why it's wrong here
Missing period.
- ✗
Error: cannot concatenate str
Why it's wrong here
No error.
- ✗
Name: Alice, Age: 30
Why it's wrong here
Not the output.
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.