PCEP Computer Programming and Python Fundamentals Practice Question
A junior developer is writing a script to read a number from input and double it. They write:
num = input("Enter a number: ") result = num * 2
print(result)
When they test with input 5, the output is '55' instead of 10. What is wrong?
⚠ Common exam trap
Candidates often assume `input()` returns a number because the user typed digits, but Python treats all keyboard input as a string, and the `*` operator's string repetition behavior is a classic PCEP trick.
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 is treated as a string; they need to convert it to int.
The `input()` function in Python always returns a string, even if the user types a number. When you use the `*` operator on a string, it repeats the string, so `'5' * 2` yields `'55'`. To perform numeric multiplication, you must convert the input to an integer using `int(input(...))`.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
There is a syntax error in the multiplication line.
Why it's wrong here
The line num * 2 is syntactically valid; a syntax error would stop execution before any output appeared. The script instead runs and prints '55'. Syntax errors arise from malformed tokens, such as a missing closing parenthesis or an unclosed string literal.
- ✗
The print function is incorrectly formatting the output.
Why it's wrong here
print() outputs whatever object it receives; here it faithfully prints the string '55' that num * 2 already produced. Formatting is not the fault. print() would be the culprit if the value were numerically correct but displayed wrongly, such as needing f-strings or separators.
- ✗
The variable name 'num' conflicts with a built-in function.
Why it's wrong here
'num' is not a Python built-in, so no shadowing occurs and the script runs without error. The real fault is input() returning a string, so * repeats it. Rebinding a genuine built-in name, such as list or sum, is the scenario where this concern applies.
- ✓
The input is treated as a string; they need to convert it to int.
Why this is correct
The built-in `input()` function always returns a string, so `num * 2` performs string repetition rather than arithmetic multiplication, producing `'55'`. Wrapping the call as `int(input("Enter a number: "))` converts the value to an integer, satisfying the requirement to double the numeric input and print `10`.
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.