Courseiva
Strings →mediumMultiple Select

PCAP Strings Practice Question

Which TWO of the following methods return a boolean value?

⚠ Common exam trap

Python Institute often tests the distinction between methods that return a new string or list versus those that return a boolean, leading candidates to mistakenly select methods like `str.upper()` or `str.split()` because they appear to perform a 'check' but actually return a transformed object.

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

✓

str.isspace()

The methods `str.isspace()` and `str.isalpha()` are both string methods that return a boolean value (`True` or `False`) based on whether the string meets specific character classification criteria. `isspace()` returns `True` if all characters in the string are whitespace, while `isalpha()` returns `True` if all characters are alphabetic.

Answer analysis

Option-by-option breakdown

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

  • ✗

    str.upper()

    Why it's wrong here

    str.upper() transforms every lowercase character in the string to uppercase and returns a brand-new string object. The method's return type is always a string, never a boolean, so using it in a condition like `if s.upper():` would be testing the truthiness of the resulting string, not receiving a True/False value from the method itself. Therefore, str.upper() is not a predicate method, even though a non-empty string is truthy.

  • ✓

    str.isspace()

    Why this is correct

    str.isspace() is a predicate method that returns True when the string is non-empty and every character in it is a whitespace character (space, tab, newline, carriage return, form feed, and similar Unicode spaces). If the string is empty or contains even one non-whitespace character, it returns False, making it useful for input validation and parsing. Thus, it directly answers the question's requirement of returning a boolean value.

  • ✗

    str.split()

    Why it's wrong here

    str.split() splits a string into a list of substrings based on a delimiter (whitespace by default) and returns a list, not a boolean. Because the result is a container, you might mistake its truthiness for a boolean, but the method's actual return type is list, and list objects are not booleans. str.split() cannot be used as a predicate method, so it is incorrect for the question.

  • ✗

    str.join()

    Why it's wrong here

    str.join() takes an iterable of strings and concatenates them with the string it is called on as a separator, returning a single new string. The return type is str, which is why it does not qualify as a method returning a boolean value. Even if the joined result is empty, the method returns an empty string, not False, so it never produces a boolean outcome.

  • ✓

    str.isalpha()

    Why this is correct

    str.isalpha() is a predicate method that returns True if the string is non-empty and all its characters are alphabetic letters, as defined by Unicode (which includes letters from many scripts). For an empty string or a string containing digits, punctuation, or symbols, it returns False. Because its only possible return values are the boolean literals True and False, it is a correct answer to the question.

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.