Sets in Python (Overview)
In this course, you’ll learn about sets. They’re a useful data structure that allows you to do some complex operations more easily. They come up everywhere in the real world and are important to understand.
By the end of this course, you’ll know:
- What a set is
- How to define a set in Python
- How to operate on a set
- How to modify a set
- When to use sets
- Why sets are a good choice for checking membership
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?”
Become a Member to join the conversation.