PCAP Strings Practice Question
Which TWO of the following string methods return a boolean value (True or False)?
⚠ Common exam trap
Python Institute often tests the distinction between methods that return a boolean versus those that return a new string or an integer, trapping candidates who confuse `str.find()` (returns index) with `str.startswith()` (returns boolean).
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.startswith()
Both `str.startswith()` and `str.isdigit()` return a boolean value (`True` or `False`) because they are designed for conditional checks. `str.startswith()` checks if the string starts with a given prefix, while `str.isdigit()` checks if all characters in the string are digits. In contrast, `str.upper()` returns a new string, `str.split()` returns a list, and `str.find()` returns an integer index. Therefore, options C and D are the correct answers.
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() is a transformation method: it returns a brand-new string with every cased character converted to uppercase, leaving the original unchanged. Because the returned object is always of type str, not True or False, it cannot serve as a boolean predicate in a condition such as if s.upper(): — that expression would simply test whether the returned string is non-empty, not whether something is true about the original content.
- ✗
str.split()
Why it's wrong here
str.split() is a parsing method that returns a list of substrings, splitting the original string at whitespace or at a specified separator. The result is always a list object, never a bool, so it lacks the Yes/No answer that a predicate method must provide. Even a one-element list like ['abc'] is truthy, but that is a general container truthiness rule, not a boolean return value.
- ✓
str.startswith()
Why this is correct
str.startswith() is a predicate method: it evaluates the string against a condition and returns the boolean value True if the string begins with the given prefix, otherwise False. It also accepts optional start and end index arguments to scope the check, and can take a tuple of prefixes to test multiple alternatives at once. Because its entire purpose is to answer a Yes/No question about string content, it is one of the methods that truly returns a bool.
- ✓
str.isdigit()
Why this is correct
str.isdigit() is a character-classification predicate that returns True only if the string contains at least one character and every character is a digit according to Unicode, including digits like '5' but not negative signs or decimal points. The method deliberately returns a strict bool, not an integer, so it can be used directly in validation logic like if user_input.isdigit(). This makes it a second clear example of a string method that returns a boolean value.
- ✗
str.find()
Why it's wrong here
str.find() returns an int: the lowest index at which the specified substring occurs, or -1 when the substring is absent. Although -1 and 0 can be treated as truthy or falsy in a boolean context, the method itself does not return True or False. Its purpose is to locate a position, not to classify a property, so it is not a boolean-returning method and belongs with the wrong answers.
Go deeper
Related to this 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 →
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.