PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
Exhibit
Enter name: Bob Hello Bob
Refer to the exhibit. The code used is: name = input('Enter name: '); print('Hello', name). What will be printed if the user enters 'Alice'?
⚠ Common exam trap
Python Institute often tests whether candidates understand that `input()` returns the actual typed value, not a predefined string, and that `print()` with a comma separator adds a space automatically, which can confuse those expecting concatenation with `+`.
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
✓
Hello Alice
The `input()` function captures the user's typed input as a string, and the `print()` function outputs the string 'Hello ' followed by the value of the `name` variable. When the user enters 'Alice', `name` becomes 'Alice', so the output is 'Hello Alice'.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Hello Bob
Why it's wrong here
The variable `name` receives whatever the user types, so entering 'Alice' prints 'Hello Alice'; 'Bob' is never assigned anywhere in the code. It is tempting because 'Bob' is a common placeholder in examples, but the output depends solely on the runtime input supplied.
- ✗
Error
Why it's wrong here
`input()` returns a string and `print()` accepts it without error, so entering 'Alice' produces 'Hello Alice'. An error would occur only if the input were converted, for example with `int()`, and the text were non-numeric; no such conversion appears here.
- ✓
Hello Alice
Why this is correct
The comma in `print('Hello', name)` inserts a single space between its arguments, so the output is `Hello Alice`. This satisfies the stem's exact input, `Alice`, and the requirement to show precisely what the program prints, including that separating space.
- ✗
Hello name
Why it's wrong here
`print('Hello', name)` outputs the string 'Hello' followed by the value bound to `name`, which is 'Alice', not the literal identifier. It is tempting because the source text contains the token `name`, but Python evaluates the variable rather than echoing its name.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 482 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.