PCAP Strings Practice Question
Exhibit
name = "Alice"
age = 25
txt = f"{name:>10} is {age:03d} years old."
print(txt)Refer to the exhibit. What is printed?
⚠ Common exam trap
Python Institute often tests the subtle distinction between string padding (spaces) and numeric zero-padding, and the fact that the `>` alignment specifier applies to strings while `0` padding applies only to numbers, causing candidates to overlook the leading spaces or the zero-padded age.
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 025 years old.'
The Python code uses an f-string with the format specifier `:>10s}` for the name and `:03d}` for the age. The `>10s` right-aligns the string 'Alice' in a field of width 10, producing 5 leading spaces. The `03d` formats the integer 25 as a zero-padded three-digit string '025'. The final output is `' Alice is 025 years old.'`.
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 025 years old.'
Why this is correct
Correct: name right-aligned, age zero-padded.
- ✗
' Alice is 25 years old.'
Why it's wrong here
Same as C.
- ✗
'Alice is 25 years old.'
Why it's wrong here
This would be left-aligned.
- ✗
' Alice is 25 years old.'
Why it's wrong here
Missing zero-padding.
Go deeper
Related to this question
About these practice questions
One of 169 original PCAP 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 PCAP 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 PCAP exam.