PCEP Control Flow, Loops, Lists and Logic Practice Question
Exhibit
mylist = [0, 1, 2, 3] print(mylist[1:3])
Refer to the exhibit. What is the output?
⚠ Common exam trap
A common mistake is confusing slice indices with the values themselves or misapplying the stop index (exclusive). Candidates might think `[:2]` includes index 2, giving [1,2,3], or that it starts at index 1, giving [2,3].
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
✓
[1, 2]
The code creates a list [1,2,3] and uses slicing with start index 0 and end index 2 (exclusive), extracting elements at indices 0 and 1, which are 1 and 2. Therefore, the output is [1,2].
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
[1, 2, 3]
Why it's wrong here
Slice excludes end index.
- ✗
[0, 1, 2]
Why it's wrong here
Start should be 1, not 0.
- ✓
[1, 2]
Why this is correct
Correct slice.
- ✗
[2, 3]
Why it's wrong here
Start should be 1, not 2.
Go deeper
Related to this question
About these practice questions
Courseiva writes every PCEP question from scratch — 498 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 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.