PCAP Strings Practice Question
A developer wants to convert a string 'Python' to all uppercase letters. Which string method should be used?
⚠ Common exam trap
The Python PCAP exam often tests the distinction between `upper()` and `capitalize()` or `title()`, where candidates mistakenly choose `capitalize()` thinking it converts the entire string to uppercase, but it only capitalizes the first character.
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
✓
upper()
The `upper()` method returns a copy of the string with all lowercase characters converted to uppercase. Since the goal is to convert 'Python' to 'PYTHON', `upper()` is the correct and most direct method for this task.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
capitalize()
Why it's wrong here
The `str.capitalize()` method returns a new string in which only the first character is converted to uppercase and all remaining characters are coerced to lowercase. For the input `'Python'`, this method produces `'Python'` (since the first letter is already uppercase and the rest are already lowercase), not the desired `'PYTHON'`. Even for a string like `'pYTHON'`, `capitalize()` would yield `'Python'`, so it fails to uppercase every character.
- ✗
title()
Why it's wrong here
The `str.title()` method transforms the string so that the first letter of each word is uppercase and all other letters are lowercase, using Unicode word-boundary rules. When applied to the single-word string `'Python'`, it returns `'Python'` unchanged because the word already follows title-case conventions. This method does not produce `'PYTHON'`; it only uppercases word-initial characters, not every alphabetic character, so it is not suitable for a full uppercase conversion.
- ✗
swapcase()
Why it's wrong here
The `str.swapcase()` method reverses the case of every alphabetic character in the string: each lowercase letter becomes uppercase and each uppercase letter becomes lowercase. Calling it on `'Python'` yields `'pYTHON'`, because the leading `'P'` is lowered while `'ython'` is uppercased. This is fundamentally the opposite of the requested all-uppercase output, so it cannot satisfy the developer's goal.
- ✓
upper()
Why this is correct
The `str.upper()` method returns a new string with all alphabetic characters converted to uppercase, leaving non-alphabetic characters unchanged. For the string `'Python'`, it produces `'PYTHON'` without modifying the original string, satisfying the requirement for a non-destructive transformation. This method operates on each Unicode character’s case mapping, ensuring correct conversion for the given ASCII input.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCAP question from scratch — 169 in total, each with an explanation and a wrong-answer breakdown. None are copied from real exams or dumps. 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.