Courseiva
Strings →mediumMatching

PCAP Strings Practice Question

Match each string method to its purpose.

Drag a concept onto its matching description — or click a concept then click the description.

Concepts
Matches

Returns uppercase copy

Splits into list of substrings

Removes leading/trailing whitespace

Replaces occurrences of a substring

Returns index of first occurrence

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(): Converts all characters to uppercase.

The correct matches are: .upper() converts to uppercase, .lower() converts to lowercase, .strip() removes leading/trailing whitespace. Common confusions include swapping .split() and .replace(), and confusing .replace() with .upper().

Answer analysis

Option-by-option breakdown

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

  • ✓

    upper(): Converts all characters to uppercase.

    Why this is correct

    The upper() method returns a new string in which every cased character has been converted to its uppercase equivalent according to Unicode, leaving non-cased characters and the original string untouched. It is correct here because the stated purpose exactly matches this behavior. Note that because strings are immutable, the return value must be assigned or used, not assumed to mutate the original.

  • ✓

    lower(): Converts all characters to lowercase.

    Why this is correct

    The lower() method produces a copy of the string with all cased characters converted to lowercase, using Unicode case folding rules. It is correct because the purpose describes precisely what this method does, and it does not alter the original string in place. This is distinct from upper(), which performs the reverse conversion.

  • ✓

    strip(): Removes leading and trailing whitespace.

    Why this is correct

    The strip() method removes leading and trailing whitespace—such as spaces, tabs, newlines—from both ends of the string, but it never removes whitespace inside the text. It is correct because the description captures the method's core purpose of cleaning outer padding. An optional argument can specify a different set of characters to trim, but the default behavior matches this statement.

  • ✗

    split(): Replaces all occurrences of a substring with another.

    Why it's wrong here

    The split() method breaks a string into a list of substrings by dividing it at a specified separator, defaulting to runs of whitespace. It does not replace anything in the string; replacement is the job of the replace() method. Thus the description is incorrect because it describes replace(), not split().

  • ✗

    join(): Splits the string into a list of substrings.

    Why it's wrong here

    The join() method does the opposite of splitting: it takes an iterable of strings and concatenates them together, using the string it is called on as the separator between items. It cannot split a string into a list, so the description is wrong. The operation described belongs to split(), which parses a string into list elements.

  • ✗

    replace(): Converts all characters to uppercase.

    Why it's wrong here

    The replace() method returns a new string where every occurrence of a given substring has been substituted with a different substring, e.g., 'a:b'.replace(':', '/') yields 'a/b'. It performs no case conversion whatsoever, so the description is incorrect. The behavior described is that of upper(), which changes letters to uppercase.

About these practice questions

This PCAP question is part of Courseiva's 421-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. 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 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.