CertGrid CertGrid
Concepts·Certified Entry-Level Python Programmer

Python List Methods and Copying

The second half of objective 3.1. The methods are easy to list and easy to get wrong in one specific way: the mutating ones return `None`, so `xs = xs.sort()` destroys the list. Copying is the deeper subject - `b = a` gives two names for one list, `a[:]` gives a real copy, and neither copies the lists *inside* a list. That last point is where PCAP's most-asked OOP question comes from.

Data Collections Guide 14 of 26 Beginner

Written against the versions above. Nothing here is version-dependent. `list.copy()` was added in Python 3.3 and is equivalent to `xs[:]`; both are shown, because a question may use either.

One machine, and any shell with Python 3 will do - these exams test the language, not a distribution.
Server NameIP AddressOSRolesCPURAMHDD
RUNNER01192.168.0.27Ubuntu 26.04 LTSPython 3.14.4 - the only machine this path needs2 Core4 GB50 GB

Before you start

  1. The methods that add

  2. The methods that remove

  3. How removal fails

  4. sort() returns None, sorted() returns a list

  5. What cannot be sorted

  6. Searching and counting

  7. index() on something absent

  8. b = a does not copy anything

  9. A copy of a list of lists is not a copy of the inner lists

  10. The repetition trap

  11. What the exam does with this half of the objective

Official sources