Question 239 of 511
StringshardMultiple ChoiceObjective-mapped

Quick Answer

The correct answer is HI, WORLD! because the `upper()` method on strings returns a new string where every lowercase letter is converted to uppercase, leaving numbers, spaces, and punctuation unchanged. In the given code, the string `'Hi, World!'` contains the lowercase letters `i` and `orld`, which become `I` and `ORLD`, while the capital `H` and `W` remain as is, producing the output `'HI, WORLD!'`. This question tests your understanding that string methods in Python are non-destructive—they do not alter the original string but instead return a new string object. On the Certified Associate Python Programmer PCAP exam, the `upper()` method frequently appears alongside `lower()`, `capitalize()`, and `title()` in questions about string immutability and method chaining. A common trap is assuming the method modifies the string in place, but Python strings are immutable, so the original `'Hi, World!'` stays unchanged. To remember: think of `upper()` as shouting the string—every letter gets louder, but the punctuation stays quiet.

PCAP Strings Practice Question

This PCAP practice question tests your understanding of strings. Read the scenario carefully and evaluate each option against the stated constraints before committing to an answer. After answering, compare your reasoning against the explanation and wrong-answer breakdown below. Once you have made your selection, read the full explanation to reinforce the concept and understand why each distractor is designed to mislead on exam day.

Exhibit

text = 'Hello, World!'
result = text.replace('Hello', 'Hi').upper()
print(result)

Refer to the exhibit. What is the output?

Question 1hardmultiple choice
Full question →

Exhibit

text = 'Hello, World!'
result = text.replace('Hello', 'Hi').upper()
print(result)

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 correct answer is D because 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.

Key principle: Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

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

    Missing .upper() result.

  • Hello, World!

    Why it's wrong here

    No operations applied.

  • HELLO, WORLD!

    Why it's wrong here

    Replacement did not happen.

  • HI, WORLD!

    Why this is correct

    Correct after both operations.

    Related concept

    Read the scenario before looking for a memorised answer.

Common exam traps

Common exam trap: answer the scenario, not the keyword

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!'.

Detailed technical explanation

How to think about this question

The `upper()` method in Python is a string method that returns a copy of the string with all cased characters converted to uppercase. It uses Unicode character mapping, so it handles international characters correctly (e.g., 'é' becomes 'É'). This method is locale-independent in Python 3, meaning it does not consider locale-specific rules for case conversion, unlike `str.casefold()` which is more aggressive for caseless matching.

KKey Concepts to Remember

  • Read the scenario before looking for a memorised answer.
  • Find the constraint that changes the correct option.
  • Eliminate answers that are true in general but not in this case.

TExam Day Tips

  • Watch for words such as best, first, most likely and least administrative effort.
  • Review why wrong options are wrong, not only why the correct option is correct.

Key takeaway

Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option.

Real-world example

How this comes up in practice

A cloud solutions architect for a retail company is evaluating services for a new workload. The correct answer here reflects best practice for the specific scenario described — not a general cloud recommendation. Answer the scenario, not the keyword: identify the specific constraint before choosing the most familiar-sounding option. Cloud exam questions reward reading the constraint carefully: the same technology can be right or wrong depending on the use case.

What to study next

Got this wrong? Here's your next step.

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

Related practice questions

Related PCAP practice-question pages

Use these pages to review the topic behind this question. This is how one missed question becomes focused revision.

Practice this exam

Start a free PCAP practice session

Short sessions build daily habit. Longer sessions build exam-day stamina. Try a timed session to simulate real conditions.

FAQ

Questions learners often ask

What does this PCAP question test?

Strings — This question tests Strings — Read the scenario before looking for a memorised answer..

What is the correct answer to this question?

The correct answer is: HI, WORLD! — The correct answer is D because 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.

What should I do if I get this PCAP question wrong?

Identify which exam domain this question belongs to, review the core concept, then practise similar questions from the same domain.

What is the key concept behind this question?

Read the scenario before looking for a memorised answer.

About these practice questions

Courseiva creates original exam-style practice questions with explanations and wrong-answer analysis. It does not publish real exam questions, exam dumps, or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

Keep practising

More PCAP practice questions

Last reviewed: Jun 30, 2026

Question Discussion

Share a tip, memory trick, or ask about the reasoning behind this question. Do not post real exam questions, leaked content, braindumps, or copyrighted exam material. Comments are moderated and may be removed without notice.

Loading comments…

Sign in to join the discussion.

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.