Next, we look at another of the core data types in Python: sets. This journey will also take you through the concept of hashable types.
These lessons are part of a Real Python video course by James Uejio.
Next, we look at another of the core data types in Python: sets. This journey will also take you through the concept of hashable types.
These lessons are part of a Real Python video course by James Uejio.
00:00 Hi, my name is James. Today you’ll be learning about sets. In Section 1, you’ll get an introduction to sets and learn “What is a set?”, immutable versus hashable, and how to define a set in Python. In Section 2, you’ll learn different ways to operate on a set. For example, how to get the length of a set, how to check membership, and iterate through a set.
00:20 You’ll also learn how to get the union, intersection, and difference of sets; how to check if a set is disjoint of another set; and how to check if a set is a subset or a superset of another set.
00:33
In Section 3, you’ll learn different ways to modify a set. You’ll learn how to add, remove, discard, pop, and clear. You’ll learn different update methods, such as .intersection_update()
and .difference_update()
.
00:46 And you’ll learn how augmented assignment works for sets. In Section 4, you’ll learn about frozen sets and conclude on why we care about sets. So, frozen sets and augmented assignment, which work differently for frozen sets than they do for regular sets.
01:04 You,’ll also learn “Why sets?” and run through a speed test comparing sets with lists and tuples. So, let’s get started with defining “What is a set?”
You must own this product to join the conversation.