35 Working with Set

 

After reading this lesson, you will be able to

  • Perform union, intersection, and difference operations on sets
  • Inquire about the properties of a set
  • Select one of a set’s elements based on its features
  • Filter its items according to their characteristics

In the previous lesson, you learned about the structure of a set and how to transform its elements. In this lesson, you’ll discover other methods that the class Set has to offer. You’ll apply the operations of union, intersection, and difference on two sets. Then, I’ll introduce you to more complex transformations. You’ll notice a lot of overlap with the concepts you discovered for the List collection in unit 5. You’ll inquire about the properties of a set, such as its size or the presence of an item. You’ll select one of its elements based on its characteristics and determine its minimum and maximum. You’ll filter its values based on their features. In the capstone, you’ll use these operations to analyze the book loans of your library.

35.1 The Union, Intersection, and Difference operations

Let’s consider the program to track students and their selected topics you saw in the previous lesson. Suppose you want to identify students based on their topic selection.

35.2 Other operations on Set

Summary

Answers to quick checks