PCAP Strings Practice Question
Exhibit
text = 'Hello, World!'
result = text.replace('Hello', 'Hi').upper()
print(result)Refer to the exhibit. What is the output?
⚠ Common exam trap
Python Institute often tests whether candidates notice the exact original string value, as many mistakenly assume the output is 'HELLO, WORLD!' from a common greeting like 'Hello, World!' rather than the actual string 'Hi, World!'.
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
✓
HI, WORLD!
The code uses the `upper()` method on the string `'Hi, World!'`, which converts all lowercase letters to uppercase. The output is `'HI, WORLD!'`. The `upper()` method does not modify the original string but returns a new string with all characters in uppercase.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Hi, World!
Why it's wrong here
This output represents only the intermediate stage of the method chain: the replace("Hello", "Hi") call successfully changes the greeting to "Hi, World!", but the .upper() step has not been applied. Since the exhibit shows the final display in all capital letters, this option omits the required case conversion and therefore cannot be the output.
- ✗
Hello, World!
Why it's wrong here
This is the original string literal exactly as it appears in the source code, before any string methods are executed. If the exhibit includes a replace() and an upper() call, the output must differ from the input; selecting this option would assume that neither transformation was applied, which contradicts the operation sequence that produces the displayed result.
- ✗
HELLO, WORLD!
Why it's wrong here
Applying only .upper() to the original "Hello, World!" yields "HELLO, WORLD!", converting every letter to uppercase while leaving the word "HELLO" intact. The exhibit also specifies a replace() operation that changes "Hello" to "Hi", and because this option does not reflect that substitution, it represents a partial transformation rather than the final chained output.
- ✓
HI, WORLD!
Why this is correct
This is the correct result after executing both operations in sequence: first, replace("Hello", "Hi") changes the string to "Hi, World!"; second, upper() converts every alphabetic character to uppercase, producing "HI, WORLD!". The order of the chain matters—the replacement happens before case conversion, so the greeting becomes "HI" instead of "HELLO", matching the exhibited output exactly.
Go deeper
Related to this question
About these practice questions
One of 421 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.