Courseiva

PCEP Computer Programming and Python Fundamentals Practice Question

What is the output of the following code?

print('Hello'.upper())

⚠ Common exam trap

The PCEP exam often tests whether candidates understand that `.upper()` does not add or remove characters—it only changes the case of alphabetic characters, so any extra punctuation or unchanged casing indicates a misunderstanding of the method's exact behavior.

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

✓

HELLO

The `.upper()` string method in Python returns a new string with all lowercase letters converted to uppercase. The string `'Hello'` contains the characters 'H', 'e', 'l', 'l', 'o'; after applying `.upper()`, it becomes `'HELLO'`. The output is exactly `HELLO` without any additional characters.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✗

    hello

    Why it's wrong here

    str.upper() returns a new string with every character converted to uppercase, so the output is HELLO, not lowercase hello. It is tempting because lower() produces lowercase, and that method would be the correct choice if the code called 'Hello'.lower() instead of upper().

  • ✗

    HELLO!

    Why it's wrong here

    str.upper() converts letters to uppercase but adds no punctuation, so the result is HELLO without an exclamation mark. It is tempting because an exclamation can appear in printed greetings, but that would require the source string to contain '!' or an explicit concatenation, neither of which occurs here.

  • ✓

    HELLO

    Why this is correct

    The `upper()` string method returns a copy of the string with all cased characters converted to uppercase, leaving the original unchanged. Applied to `'Hello'`, it transforms each lowercase letter, producing `HELLO`. This satisfies the stem's requirement to determine the exact printed output of the expression.

  • ✗

    Hello

    Why it's wrong here

    str.upper() transforms the string, returning HELLO; it does not preserve the original mixed-case Hello. It is tempting because Hello is the literal input, and that would be the output if the code printed the string without calling any method, but upper() changes it.

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 →

How Courseiva writes practice questions · Editorial policy

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.