Collections

6. Collections#

This chapter presents Python collections for storing multiple values: lists, tuples, and sets. You will compare ordered, mutable, immutable, and unique-value containers so you can choose the right structure for a task.

  • Creating and using lists, tuples, and sets

  • Accessing ordered collections with indexes and slices

  • Adding, removing, and transforming mutable collections

  • Comparing mutability, aliasing, copying, and uniqueness

  • Applying common collection idioms used in everyday Python

Video

This overview introduces Python sequence containers, including lists and tuples, and contrasts them with sets.

Learning Goals

By the end of this chapter, you will be able to:

  1. Construct and manipulate Python lists using indexing, slicing, and core list methods

  2. Explain object identity, aliasing, shallow copies, and deep copies

  3. Predict how lists behave when passed to functions

  4. Use list comprehensions, unpacking, enumerate(), zip(), and sorting patterns

Chapter Flow

Chapter Overview Slides