PCAP Python String Processing Quiz

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Thames
T
Thames
Community Contributor
Quizzes Created: 11982 | Total Attempts: 187,298
| Attempts: 11 | Questions: 20 | Updated: Aug 16, 2026
Please wait...
Question 1 / 21
🏆 Rank #-- ▾
0 %
0/100
Score 0/100

1. What does 'test'.isdigit() return?

Explanation

In Python, `str.isdigit()` returns `True` only when every character in the string is a digit and the string is not empty. Since `'test'` contains letters rather than digits, `'test'.isdigit()` evaluates to `False`.

Submit
Please wait...
About This Quiz
PCAP Python String Processing Quiz - Quiz

This quiz evaluates your mastery of Python string processing techniques essential for the PCAP certification. Test your knowledge of string methods, formatting, slicing, and manipulation through practical scenarios. Perfect for college-level learners preparing for professional Python certification.

2.

What first name or nickname would you like us to use?

You may optionally provide this to label your report, leaderboard, or certificate.

2. Which method removes all occurrences of a substring from a string?

Explanation

Calling `replace(substring, '')` substitutes every occurrence of the specified substring with an empty string, effectively removing it. By default, `replace()` processes all occurrences in the string. The other options do not provide this behavior for removing every matching substring.

Submit

3. What does 'hello world'.endswith('world') return?

Explanation

`endswith('world')` checks whether the string ends with the specified suffix. Since `'hello world'` ends with `'world'`, the method returns `True`.

Submit

4. How do you repeat a string 'ab' three times?

Explanation

In Python, the `*` operator repeats a string the specified number of times. So `'ab' * 3` produces `'ababab'`.

Submit

5. What does '{} {}'.format('hello', 'world') return?

Explanation

In Python, each `{}` is an unnumbered replacement field. The `format()` method fills them in order with `'hello'` and `'world'`, while the space between the fields remains unchanged, producing `hello world`.

Submit

6. Which method checks if all characters in a string are alphanumeric?

Explanation

`isalnum()` returns `True` when every character in a non-empty string is a letter or a digit. It returns `False` if the string contains spaces or punctuation. By contrast, `isalpha()` checks for letters only, `isdigit()` checks for digits only, and `isspace()` checks for whitespace.

Submit

7. What is the output of 'python'[1:4]?

Explanation

Python slicing includes the starting index and excludes the ending index. In `'python'[1:4]`, the characters at indices 1, 2, and 3 are `y`, `t`, and `h`, producing `yth`.

Submit

8. Which method converts a string to title case?

Explanation

In Python, `title()` returns a string with the first character of each word capitalized and the remaining characters converted to lowercase. `capitalize()` changes only the start of the entire string, `upper()` makes all letters uppercase, and `format()` inserts values into a string.

Submit

9. What does 'hello'.count('l') return?

Explanation

In Python, `str.count()` returns the number of times the specified substring appears. The letter `'l'` occurs twice in `'hello'`, so `'hello'.count('l')` returns `2`.

Submit

10. How do you join a list ['a', 'b', 'c'] into a single string with '-' separator?

Explanation

In Python, `join()` is called on the separator string. `'-'.join(['a', 'b', 'c'])` combines the list elements into one string, placing `-` between each element, producing `'a-b-c'`.

Submit

11. What is the output of 'hello world'.upper()?

Explanation

The `upper()` method returns a new string with all lowercase letters converted to uppercase. It leaves the space between the words unchanged, producing `HELLO WORLD`.

Submit

12. Which method returns the index of the first occurrence of a substring?

Explanation

For strings, `find()` searches for a specified substring and returns the index of its first occurrence. If the substring is not found, it typically returns `-1`.

Submit

13. What is 'PYTHON'.lower()?

Explanation

The `lower()` method converts all uppercase letters in a string to lowercase. Therefore, `'PYTHON'.lower()` returns `python`.

Submit

14. How do you format a string with variables using f-strings? For example, name='Alice', age=25.

Explanation

Prefix the string with `f` to create an f-string, then place variable names inside curly braces. Python replaces `{name}` and `{age}` with their values, producing `Name: Alice, Age: 25`.

Submit

15. What does 'hello'.startswith('he') return?

Explanation

`startswith('he')` checks whether the string begins with the prefix `'he'`. Since `'hello'` starts with those two characters, the method returns the Boolean value `True`.

Submit

16. Which slicing returns the last 3 characters of 'example'?

Explanation

In Python, a negative index counts backward from the end of a string. The slice `example[-3:]` starts at the third character from the end and, because no stop index is given, continues to the end, returning `'ple'`.

Submit

17. What is the result of 'a,b,c'.split(',')?

Explanation

The `split(',')` method divides the string wherever it finds a comma and returns the resulting parts as a list. Therefore, `'a,b,c'` becomes `['a', 'b', 'c']`.

Submit

18. How do you check if 'cat' is in 'concatenate'?

Explanation

Use the `in` operator to check whether one string appears within another. Since `"cat"` occurs in `"concatenate"`, the expression `'cat' in 'concatenate'` evaluates to `True`.

Submit

19. What does 'python'.replace('p', 'j') return?

Explanation

The `replace('p', 'j')` method replaces the letter `p` in `'python'` with `j`, returning the new string `'jython'`.

Submit

20. Which method removes leading and trailing whitespace from a string?

Explanation

`strip()` removes whitespace from both the beginning and end of a string. It does not remove whitespace between words or within the string.

Submit
×
Saved
Thank you for your feedback!
View My Results
Cancel
  • All
    All (20)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
What does 'test'.isdigit() return?
Which method removes all occurrences of a substring from a string?
What does 'hello world'.endswith('world') return?
How do you repeat a string 'ab' three times?
What does '{} {}'.format('hello', 'world') return?
Which method checks if all characters in a string are alphanumeric?
What is the output of 'python'[1:4]?
Which method converts a string to title case?
What does 'hello'.count('l') return?
How do you join a list ['a', 'b', 'c'] into a single string with '-'...
What is the output of 'hello world'.upper()?
Which method returns the index of the first occurrence of a substring?
What is 'PYTHON'.lower()?
How do you format a string with variables using f-strings? For...
What does 'hello'.startswith('he') return?
Which slicing returns the last 3 characters of 'example'?
What is the result of 'a,b,c'.split(',')?
How do you check if 'cat' is in 'concatenate'?
What does 'python'.replace('p', 'j') return?
Which method removes leading and trailing whitespace from a string?
play-Mute sad happy unanswered_answer up-hover down-hover success oval cancel Check box square blue
Alert!