PCEP Computer Programming and Python Fundamentals Practice Question
A developer writes the following code:
values = [10, 20, 30, 40, 50] result = values[1:4]
What does the variable result contain after execution?
⚠ Common exam trap
The trap here is treating the second slice index as inclusive, which shifts the result by one element and changes both the start and stop boundaries.
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
✓
[20, 30, 40]
List slicing takes a start index that is included and a stop index that is excluded. With values[1:4], the slice begins at the element twenty and continues through the elements at indexes two and three, which are thirty and forty. The element at index four is not included because the stop bound is exclusive, so the result list holds three elements.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
[20, 30, 40]
Why this is correct
Slicing uses a start index that is included and a stop index that is excluded. Starting at index one includes twenty, and stopping at index four excludes the element at index four, which is fifty. The elements at indexes one, two, and three are twenty, thirty, and forty, so the resulting list contains exactly those three values.
- ✗
[20, 30, 40, 50]
Why it's wrong here
Including fifty would mean the stop index was five or omitted entirely, as in values[1:] or values[1:5]. The stop value four is exclusive, so the element at index four is never part of the result. This option treats the stop index as inclusive, which contradicts Python's slicing rules.
- ✗
[10, 20, 30]
Why it's wrong here
This slice corresponds to values[0:3], which begins at the first element and stops before index three. The code starts at index one and stops before index four, shifting the window one position to the right. The element ten at index zero is excluded, and forty is included, so this option does not match the code.
- ✗
[10, 20, 30, 40]
Why it's wrong here
This slice would require starting at index zero and stopping before index four, written as values[0:4]. The code instead starts at index one, which skips the first element, ten. The stopping index four is also exclusive, so the element at index four, fifty, is omitted. This option therefore misreads both boundaries of the slice.
About these practice questions
This PCEP question is part of Courseiva's 482-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official Python Institute exam blueprint
This PCEP 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 PCEP exam.