Part 3 · Section 05

Sets

A set is what you get if you take a dictionary and throw away the values: an unordered collection of distinct, hashable objects, stored in a hash table. That one design decision gives sets their two superpowers. Membership tests take roughly constant time no matter how big the set is, and duplicates simply can’t exist. On top of that, Python gives sets the full vocabulary of mathematical set theory, with both operators and methods.

In this section you’ll learn:

Lectures

  1. 01Creating Sets✓
  2. 02Common Set Operations✓
  3. 03Set Operations✓
  4. 04Update Operations✓
  5. 05Copying Sets✓
  6. 06Frozen Sets✓
  7. 07Dictionary Views✓

Practice: quiz & exercises

12 quiz questions · 4 coding exercises

Go to practice →