Making operations on sets as methods
You've already learned about operators that allow you to combine sets. These operators are as similar as possible to those used in set theory in mathematics. Every programmer should at least know the basics of set theory. For this reason, we should use sets in combination with operators.
However, we should mention that each operator has a verbal equivalent method:
a.union(b) # equivalent "a | b"
a.intersection(b) # equivalent "a & b"
a.difference(b) # equivalent "a - b"
a.symmetric_difference(b) # equivalent "a ^ b"
Updating of sets in place
There is another reason why we're talking about the four methods above. Remember, we looked at the dictionary update
method, updating the dictionary locally using data from another dictionary? There are several of these sorts of update methods.