Courseiva
Strings →mediumMultiple Select

PCAP Strings Practice Question

Which THREE of the following string methods return a boolean value (True or False)? (Choose exactly 3 correct answers.)

⚠ Common exam trap

Python Institute often tests the distinction between methods that return a boolean versus those that return an integer or a new string, and the trap here is that candidates confuse `find()` (returns index) with `in` operator (returns boolean) or assume `replace()` returns a boolean because it modifies the string in some contexts.

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

✓

isspace()

The `isspace()` method returns `True` if all characters in the string are whitespace characters (e.g., space, tab, newline) and the string is non-empty; otherwise, it returns `False`. This is a boolean-returning method that checks a specific character property, making option A correct.

Answer analysis

Option-by-option breakdown

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

  • ✓

    isspace()

    Why this is correct

    isspace() is a string predicate method that returns True only when the string is non-empty and every character in it is classified as whitespace by Python, including the space character, tab '\t', newline '\n', carriage return '\r', and other Unicode whitespace characters. Because it performs a character-by-character truth check and produces a boolean result, it is one of the valid answers to this question.

  • ✓

    isalpha()

    Why this is correct

    isalpha() returns True only if the string contains at least one character and all those characters are alphabetic letters. Crucially, Python's definition of alphabetic extends beyond ASCII: it recognizes Unicode letters such as 'é' or 'α' as alphabetic, but it does not count digits, punctuation, or whitespace. This makes it a boolean-returning classifier method, so it is correct.

  • ✓

    isdigit()

    Why this is correct

    isdigit() is another boolean-returning classifier: it returns True only for non-empty strings where every character is a digit character, including Unicode digits like '2' in superscript form (e.g., '²'). It specifically checks the digit property, not numeric value, so characters like '½' or negative signs cause it to return False. This distinguishes it from methods that return strings, indexes, or other non-boolean types.

  • ✗

    replace()

    Why it's wrong here

    replace() is a transformation method, not a predicate: it takes an old substring and a new substring, then returns a brand-new string with all (or a specified count of) occurrences replaced. The result is always a str object, never a boolean value, and the original string remains unchanged because strings are immutable. Since its return type is fundamentally wrong for a boolean question, it is incorrect.

  • ✗

    find()

    Why it's wrong here

    find() is a search method that returns the lowest index (an integer) where the specified substring occurs in the string, or -1 if the substring is not present. Although in boolean contexts -1 is truthy and 0 is falsy, find() itself does not return True/False; it returns a position or a sentinel value. That integer return type makes it ineligible as one of the boolean-returning methods.

About these practice questions

Courseiva writes every PCAP question from scratch — 421 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 →

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.