PCEP Control Flow, Loops, Lists and Logic Practice Question
Which THREE of the following are valid list operations?
⚠ Common exam trap
Python Institute often tests the distinction between list methods and methods from other data structures (like `add()` for sets or `push()` for stacks) to catch candidates who confuse Python's list API with those of other languages or collections.
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
✓
my_list.extend([5,6])
Option B, my_list.extend([5,6]), is valid because Python lists provide the extend() method, which appends each element of the given iterable to the end of the list, so [5,6] adds two separate items. Option D, my_list.insert(0,5), is valid because insert(index, value) is a standard list method that places the value 5 at index 0, shifting existing elements to the right. Option E, my_list.append(5), is valid because append() is the canonical list method for adding a single element to the end of the list. Option A, my_list.add(5), is not a list operation; add() belongs to set objects, not lists. Option C, my_list.push(5), is not a Python list method; push() is associated with stack-like structures in other languages (e.g., JavaScript arrays), whereas Python lists use append().
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
my_list.add(5)
Why it's wrong here
Python lists expose append, extend and insert; add belongs to sets, so my_list.add(5) raises AttributeError. It is tempting because add genuinely mutates other Python collections, notably sets, where it inserts a single hashable element — correct there, but lists are ordered sequences with no add method.
- ✓
my_list.extend([5,6])
Why this is correct
extend() accepts an iterable and appends each of its elements individually to the end of the list, so [5,6] adds two separate items. This is a genuine list method that mutates the list in place, satisfying the valid-operation criterion.
- ✗
my_list.push(5)
Why it's wrong here
Python lists expose append, extend and insert; push belongs to stack implementations in other languages, so my_list.push(5) raises AttributeError. It is tempting because push genuinely adds elements to array-backed structures elsewhere, such as JavaScript arrays, but Python's list API never defines it.
- ✓
my_list.insert(0,5)
Why this is correct
insert() takes an index and a value, placing the value at that position and shifting subsequent elements right. insert(0,5) therefore prepends 5 to the list, and the method mutates the list in place, making it a valid list operation.
- ✓
my_list.append(5)
Why this is correct
append() adds a single object to the end of the list and mutates it in place, so append(5) appends the integer 5 as one element. This is a core list method, satisfying the valid-operation criterion.
Go deeper
Related to this question
About these practice questions
One of 482 original PCEP practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.