PCAP · topic practice

Strings practice questions

Practise Certified Associate Python Programmer PCAP Strings practice questions — original exam-style scenarios with answer choices, explanations, and analysis of common mistakes.

Courseiva uses original exam-style practice questions designed for learning and revision. The goal is to understand the concepts, recognise exam patterns, and improve through explanations — not memorise copied exam dumps.

Reviewed byJohnson Ajibi· MSc IT Security
19 questionsDomain: Strings

What the exam tests

What to know about Strings

Strings questions test whether you can apply the concept in context, not just recognise a definition.

How the topic appears in realistic exam-style scenarios.

Which detail in the question changes the correct answer.

How to eliminate plausible but wrong options.

How to connect the question back to the wider exam objective.

Watch out for

Common Strings exam traps

  • Answering from memory before reading the full scenario.
  • Missing a constraint such as cost, availability, security, scope or command context.
  • Choosing a broad answer when the question asks for the most specific fix.
  • Ignoring why the wrong options are tempting.

Practice set

Strings questions

19 questions · select your answer, then reveal the explanation

Question 1mediummultiple choice
Read the full Strings explanation →

A developer needs to count the number of occurrences of the substring 'is' in the string 'This is a test. Is this a test?'. Which code correctly performs the count?

Question 2mediummultiple choice
Read the full Strings explanation →

A programmer writes a function to check if a string is a palindrome (ignoring case and non-alphanumeric characters). Which implementation correctly achieves this?

Question 3hardmultiple choice
Read the full NAT/PAT explanation →

A log analysis script needs to extract all IP addresses from a string. The IPs are in dotted-decimal format. Which regex pattern will correctly extract them?

Question 4easymultiple choice
Read the full Strings explanation →

Which string method can be used to check if a string contains only digits?

Question 5mediummultiple choice
Read the full Strings explanation →

A developer needs to replace all occurrences of 'cat' with 'dog' in a string, but only if 'cat' is a whole word (not part of 'category'). Which code achieves this?

Question 6hardmultiple choice
Read the full Strings explanation →

Given the string s = 'Hello World!', which expression returns a list of characters?

Question 7easymultiple choice
Read the full Strings explanation →

Which of the following is the correct way to format a string with variables?

Question 9hardmultiple choice
Read the full Strings explanation →

Which of the following methods can be used to check if a string starts with a vowel?

Which TWO are valid ways to create a multiline string in Python?

Which TWO statements are true regarding strings in Python?

Which THREE are valid escape sequences in Python strings?

Question 13hardmulti select
Read the full Strings explanation →

Which THREE methods return a boolean value?

Question 14mediummultiple choice
Read the full Strings explanation →

What is the length of string s?

Exhibit

Refer to the exhibit.

Error log:
```
Traceback (most recent call last):
  File "test.py", line 3, in <module>
    print(s[15])
IndexError: string index out of range
```

Code:
```python
s = "Python Programming"
print(s[15])
```
Question 15hardmultiple choice
Read the full Strings explanation →

What is the value of matches?

Exhibit

Refer to the exhibit.

Configuration block:
```python
import re
pattern = r'\b[A-Z][a-z]*\b'
text = "Alice and Bob are friends."
matches = re.findall(pattern, text)
```
Question 16hardmultiple choice
Review the full routing breakdown →

You are a network engineer troubleshooting a script that processes router configuration files. The script reads a configuration line from a file: 'interface GigabitEthernet0/1

ip address 192.168.1.1 255.255.255.0
 no shutdown'. The script needs to extract the interface name and IP address. The current code uses string split operations but fails when the line has extra spaces or tabs. For example, when the line is 'interface   GigabitEthernet0/1', the split returns ['interface', '', '', 'GigabitEthernet0/1'] and the script fails. You need to modify the script to robustly extract the interface name and IP address regardless of whitespace. Which approach should you take?
Question 17mediummultiple choice
Read the full Strings explanation →

You are a data analyst working with a dataset of customer reviews. Each review is stored as a string in a list. You need to count how many reviews contain the word 'excellent' (case-insensitive). However, the word might appear as 'Excellent', 'EXCELLENT', or even with punctuation like 'excellent!'. The current code uses 'excellent' in review.lower(), but this fails if 'excellent' is part of another word like 'unexcellent'. You need to ensure that only the whole word 'excellent' is counted. Which code modification will correctly count whole word occurrences?

Question 18mediummultiple choice
Read the full Strings explanation →

A developer needs to parse a log file where each line contains a timestamp followed by a message. The timestamp format is 'YYYY-MM-DD HH:MM:SS'. Which string method is most appropriate to split the timestamp from the message?

Question 19easymultiple choice
Read the full Strings explanation →

A programmer writes a function that expects a string and returns it reversed. Which code snippet correctly reverses the string 'stressed' to 'desserts'?

Free account

Track your progress over time

Create a free account to save your results and see which topics improve across sessions.

Focused Strings sessions

Start a Strings only practice session

Every question in these sessions is drawn from the Strings domain — nothing else.

Related practice questions

Related PCAP topic practice pages

Move into related areas when this topic feels solid.

Frequently asked questions

What does the PCAP exam test about Strings?
Strings questions test whether you can apply the concept in context, not just recognise a definition.
How should I use these practice questions?
Select your answer before revealing the explanation. Then read why each option is right or wrong — this active recall approach builds retention far faster than re-reading notes.
Can I practise just Strings questions in a focused session?
Yes — the session launcher on this page draws every question from the Strings domain. Use a 10-question session first to gauge your baseline, then move to 20 or 30 once the weak spots are clear.
Where can I practise other PCAP topics?
Use the topic links above to move to related areas, or go back to the PCAP question bank to see all topics.
Are these real exam questions or dumps?
These are original practice questions written to test the same concepts the PCAP exam covers. They are not copied from any real exam or dump site.