Courseiva
Strings →easyMultiple Select

PCAP Strings Practice Question

Which TWO of the following string methods return a boolean value?

⚠ Common exam trap

Test-takers frequently confuse methods that return a new string (like `capitalize()`, `swapcase()`) with methods that return a boolean, because both are called on string objects and appear similar in syntax.

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

✓

startswith()

The `startswith()` method returns `True` if the string starts with the specified prefix, otherwise `False`. Similarly, `isalpha()` returns `True` if all characters in the string are alphabetic and there is at least one character, otherwise `False`. Both methods explicitly return a boolean value (`True` or `False`), making them correct choices.

Answer analysis

Option-by-option breakdown

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

  • ✓

    startswith()

    Why this is correct

    startswith() is a boolean predicate that returns True exactly when the string's prefix matches the supplied prefix, optionally constraining the check with the start and end index arguments. It never modifies the original string and its only meaningful return values are True and False, making it one of the two methods that answer the question correctly.

  • ✗

    capitalize()

    Why it's wrong here

    capitalize() performs a lexical rewrite: it produces a new string with the first character converted to titlecase and all remaining characters converted to lowercase. The returned object is always a str, even when the transformation is a no-op, so this method cannot yield a boolean result and is therefore incorrect.

  • ✗

    format()

    Why it's wrong here

    format() is a transformation method, not a predicate: it interpolates values into replacement fields and returns a fresh str object. Because its outcome is always a string (or raises an exception if the template or arguments are malformed), it can never be the source of a True/False verdict, so it does not satisfy the question.

  • ✗

    swapcase()

    Why it's wrong here

    swapcase() is another case-mapping operation, returning a new string in which every uppercase character becomes lowercase and every lowercase character becomes uppercase. Since its contract is to return a transformed string rather than to evaluate a condition, no True/False value is produced, so it is not one of the requested methods.

  • ✓

    isalpha()

    Why this is correct

    isalpha() is a predicate that returns True only if the string is non-empty and every character is alphabetic as defined by Unicode, which includes letters such as 'A', 'é', and 'β' but not digits, spaces, or punctuation. Its return type is bool, so it qualifies as a string method that returns a boolean value.

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.