Sets can be used to perform mathematical set operations like union, intersection, symmetric difference, etc.
Example:
my_set = {1, 6, 2, 'java', 'ruby', 8, 9, 10, 21, 1000, 'python', 6}
programming_set = {'java', 'ruby', 'javascript', 'python', 'c'}
print(my_set.intersection(programming_set))
print(my_set.union(programming_set))
print(my_set.difference(programming_set))
Output:
{'ruby', 'python', 'java'}
{1, 2, 'c', 6, 8, 9, 10, 1000, 'ruby', 'python', 21, 'javascript', 'java'}
{1, 2, 6, 8, 9, 10, 1000, 21}
Intersection of A and B is a set of elements that are common in both the sets.