PCAP Strings Practice Question
A developer is validating user input in a Python application. The string variable `input_str` is assigned the value `'Hello World'`. Which TWO of the following conditions evaluate to `True`? (Choose two.)
⚠ Common exam trap
Python often tests the distinction between `istitle()` and `isupper()` or `isalpha()`, trapping candidates who assume 'Hello World' is alphabetic or alphanumeric because they overlook the space character.
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
✓
input_str.istitle()
`istitle()` returns `True` when the string is titlecased, meaning the first character of each word is uppercase and all other characters are lowercase. 'Hello World' has both words starting with an uppercase letter followed by lowercase letters, so it satisfies this condition.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
input_str.isalpha()
Why it's wrong here
input_str.isalpha() returns True only when every character in the string is a Unicode alphabetic character and the string is non-empty. Because the input contains a space — a separator, not a letter — the method immediately returns False. It therefore cannot validate a phrase with word boundaries, and it will not confirm titlecase formatting.
- ✓
input_str.istitle()
Why this is correct
input_str.istitle() returns True exactly when the string is titlecased: each word boundary is followed by an uppercase letter, and all remaining letters in that word are lowercase. For a value like 'Hello World', both words start with an uppercase letter and the rest are lowercase, so the method returns True. This is the precise built-in predicate for checking titlecase, ignoring spaces and punctuation when identifying words.
- ✓
input_str.isprintable()
Why this is correct
input_str.isprintable() returns True when every character in the string is printable, including spaces, but excluding control characters such as newline or tab. Since the input is made of ordinary letters and a space, all characters are printable, so this method also returns True. It is a broader character-category check that does not assess case, format, or word structure — only visual representability.
- ✗
input_str.isalnum()
Why it's wrong here
input_str.isalnum() returns True only when every character is alphanumeric (a letter or a digit) and the string is non-empty. The space in the input is neither a letter nor a digit, so isalnum() evaluates to False. This method is useful for validating usernames or identifiers, but it rejects any whitespace separator, making it unsuitable for this titlecase phrase.
- ✗
input_str.isspace()
Why it's wrong here
input_str.isspace() returns True only when the non-empty string consists entirely of whitespace characters such as spaces, tabs, or newlines. Because the input contains letters, not just whitespace, isspace() returns False. This method is intended to detect blank or whitespace-only input, not to evaluate whether a string follows a titlecase convention.
Go deeper
Related to this question
About these practice questions
One of 421 original PCAP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.