PCEP Control Flow, Loops, Lists and Logic Practice Question
Which TWO of the following list operations modify the list in place?
⚠ Common exam trap
Python Institute often tests the difference between methods that mutate the list in place (like `sort()` and `append()`) versus operations that return a new list (like concatenation with `+` or `copy()`), trapping candidates who confuse reassignment with in-place modification.
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
✓
mylist.sort()
`mylist.sort()` sorts the list in place, meaning it modifies the original list object without creating a new one. Option E is correct because `mylist.append(5)` adds the element 5 to the end of the list, directly mutating the original list object.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
mylist.sort()
Why this is correct
`mylist.sort()` reorders the existing list object directly, returning `None` rather than a new list. This satisfies the stem's requirement for in-place modification, since the original list's element order changes without rebinding the variable to a separate object.
- ✗
mylist + [5]
Why it's wrong here
Concatenation returns a new list object, leaving mylist untouched, so it cannot satisfy an in-place requirement. It is tempting because it appears to append 5, but that is only true of mylist.append(5) or mylist += [5], which rebind or mutate the original. Use + when a separate combined list is wanted.
- ✗
mylist.copy()
Why it's wrong here
copy() produces a shallow duplicate and leaves the source list unaltered, so it performs no in-place modification. It is tempting because it is a list method that returns a list, but its purpose is duplicating for independent editing. Use it when you need a separate list sharing the same element references.
- ✗
mylist = mylist + [5]
Why it's wrong here
mylist = mylist + [5] builds a new list via concatenation and rebinds the name, leaving the original object unmodified. It is tempting because the variable appears updated afterwards, but in-place modification requires methods such as append, extend, insert, remove or sort.
- ✓
mylist.append(5)
Why this is correct
`append()` mutates the existing list object directly, adding the element to its end without creating a copy. This satisfies the stem's requirement for in-place modification, since the original list's identity and contents change. Methods such as slicing or concatenation instead return new lists, leaving the original untouched.
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.