PCAP Strings Practice Question
Exhibit
s = 'Python Programming' print(s[7:])
Refer to the exhibit. What is the output of the code?
⚠ Common exam trap
Python Institute often tests whether candidates confuse slicing indices with character positions, leading them to miscount and pick 'Program' (7 characters) instead of 'Programming' (11 characters) when extracting from index 7 onward.
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
✓
Programming
The code likely uses slicing with a start index to extract 'Programming' from the string 'Python Programming'. For instance, 'Python Programming'[7:] returns the substring starting at index 7 (after 'Python ' which is 7 characters including space) to the end, which is 'Programming'. This operation is a common way to obtain a substring.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
Program
Why it's wrong here
A slice of s[7:14] would indeed produce 'Program' because the end index is exclusive, stopping just after the 'm' at index 13. However, the code uses s[7:] with no end index, so the slice is not limited to seven characters; it continues through the final character of the string. Thus 'Program' represents a premature stop that ignores Python's half-open interval rule.
- ✓
Programming
Why this is correct
With s = 'Python Programming', index 7 points to the uppercase 'P' that begins the second word, 'Programming'. A slice of s[7:] has no explicit stop index, so Python extends it to the string's full length, outputting every character from that 'P' through the final 'g'. The result is exactly 'Programming', the complete suffix of the original string.
- ✗
Python Programming
Why it's wrong here
The entire 'Python Programming' would be returned only by a slice like s[:] or s[0:], which includes indices 0 through 17. Because the start index is explicitly 7, the first seven characters—'Python ' including the space—are excluded from the output. Therefore this option ignores the start parameter and describes an unsliced or fully sliced string, not s[7:].
- ✗
Python
Why it's wrong here
'Python' is the first word and would be obtained by s[:6], since index 6 is the space and the stop index is exclusive. Starting at index 7 bypasses the entire first word and the space, making it impossible for the slice to contain any characters from 'Python'. This answer confuses the start boundary with the end boundary of a slice.
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.