What Is a Set?
00:00 So, what is a set? Well, in mathematics, a set is a well-defined collection of distinct objects. Note the distinct. Sets cannot contain duplicates.
00:10 The set of even positive numbers less than 10 would be 2, 4, 6, and 8. The set of perfect squares less than 10 would be 1, 4, 9. The intersection of these two sets would be the number 4.
00:24 We can represent this intersection using a Venn diagram. 2, 4, 6, 8; 1, 4, 9; and the intersection is 4.
00:34
What is a set in Python? Well, Python’s built-in set
type has the following characteristics: They’re unordered. The elements are unique, and duplicate elements are not allowed.
00:47 And a set itself may be modified, but the elements inside the set must be hashable. You’ll learn about what hashable means in the next video.
Become a Member to join the conversation.