PCEP Practice Question: Data Types, Variables, Basic I/O and Operators
A developer writes: print(10 * '5'). What is the output?
⚠ Common exam trap
Watch out — candidates often confuse the string repetition operator with arithmetic multiplication, leading them to mistakenly compute 10 * 5 = 50 instead of recognizing that the operand is a string literal.
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
✓
5555555555
In Python, the multiplication operator (*) when used with a string and an integer performs string repetition. The expression 10 * '5' repeats the string '5' ten times, resulting in the string '5555555555'. The print() function then outputs this concatenated string without quotes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
10
Why it's wrong here
Multiplying a string by an integer repeats it, so 10 * '5' yields '5555555555', not the integer 10. The value 10 is the integer operand, tempting because it appears first in the expression, but Python returns the repeated string, not either operand.
- ✗
50
Why it's wrong here
Python repeats the string rather than performing numeric multiplication, so 10 * '5' produces '5555555555'. Treating '5' as a number and computing 50 confuses string repetition with arithmetic; int('5') * 10 would be needed for that result.
- ✗
5
Why it's wrong here
The result is the string '5' repeated ten times, giving '5555555555', not a single '5'. Selecting 5 mistakes the repeated character for the count; the integer 10 controls repetition, while '5' is the sequence being duplicated.
- ✓
5555555555
Why this is correct
Multiplying a string by an integer repeats it: `'5' * 10` yields ten concatenated copies, giving `5555555555`. Python's `*` operator overloads this way for sequence types, satisfying the stem's requirement that the operand order places the string second and the integer first.
Go deeper
Related to this question
About these practice questions
One of 482 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.