Collections

Learn about collections in Python.

Ali Berro

By Ali Berro

1 min read Section
From: Python Fundamentals: From Zero to Hero

Collections

Collections are a family of data structures used to store and manipulate data via algorithms. Python offers multiple collections to choose from, notable ones are:

  • Lists
  • Tuples
  • String
  • Dictionaries
  • Sets
  • Frozen Sets

Each one of these serves a different purpose and has different use cases. All of them will be covered in this chapter, in their own section.

The aforementioned collections can be classified into two main categories:

  • Sequence Structures
  • Non-Sequence Structures

Sequence structures are collections that preserve the order of the elements, like lists, tuples and strings. Non-sequence structures are collections that do not preserve the order of the elements like dictionaries sets and frozen sets.

Mutable and Immutable Collections

Collections can be mutable or immutable. Mutable collections are collections that can be changed after they are created, like lists and dictionaries. Immutable collections are collections that cannot be changed after they are created, like tuples and strings.

Note

Mutability means that something can be changed after it is created. Immutability means that something cannot be changed after it is created, we can only create a new ones.

Course Progress

Section 21 of 61

Back to Course