Courseiva

PCEP Control Flow, Loops, Lists and Logic Practice Question

Which two of the following list methods modify the original list in place? (Choose two.)

⚠ Common exam trap

Python Institute often tests the distinction between methods that mutate the list in place (like `sort()`) and functions that return a new list (like `sorted()`), as well as the fact that `count()` and `copy()` are non-mutating, to see if candidates confuse method behavior with function behavior.

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

✓

sort()

Option A, sort(), is correct because it is a list method that reorders the list's elements directly in the existing list object and returns None, so the original list is modified in place. Option D, append(), is correct because it adds a single element to the end of the existing list object and also returns None, mutating the original list. Option B, count(), is not correct because it only returns the number of occurrences of a value and does not change the list. Option C, sorted(), is not correct because it is a built-in function that returns a new sorted list, leaving the original list unchanged. Option E, copy(), is not correct because it returns a shallow copy of the list without modifying the original list.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    sort()

    Why this is correct

    sort() reorders the list object itself, mutating the existing sequence rather than returning a new list. This in-place behaviour is the axis distinguishing it from non-mutating methods such as sorted(), which builds a separate list and leaves the original untouched.

  • ✗

    count()

    Why it's wrong here

    count() only reads the list and returns the number of occurrences of a value, leaving the object unchanged. It is tempting because it is a genuine list method, but it belongs to the read-only query family; append(), extend(), insert(), remove(), pop(), clear(), sort() and reverse() are the mutators.

  • ✗

    sorted()

    Why it's wrong here

    sorted() is a built-in function that returns a new sorted list and never alters its argument. It is tempting because it sorts, but the in-place equivalent is the list method sort(), which reorders the same object; append(), extend(), insert(), remove(), pop(), clear() and reverse() also mutate in place.

  • ✓

    append()

    Why this is correct

    append() mutates the list object directly, adding its argument as a single element at the end and returning None. Because the existing list is altered rather than a copy returned, it satisfies the in-place modification requirement.

  • ✗

    copy()

    Why it's wrong here

    copy() returns a new shallow-copied list, leaving the original untouched. It is tempting because it is a real list method often used alongside in-place edits, but its purpose is duplicating a list so the source can be preserved; append(), extend(), insert(), remove(), pop(), clear(), sort() and reverse() mutate in place.

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 →

How Courseiva writes practice questions · Editorial policy

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.