Account
Categories

Intersection Operation


Definition:

If you need common values from two sets, then it creates a third set with the common values. This is called the Intersection Operation.

Syntax:

result = set1 & set2
# or
result = set1.intersection(set2)

Example:

a = {1, 2, 3}
b = {2, 3, 4}

result = a & b
print(result)

Output:

Exercise

Find the intersection of sets a = {10, 20, 30} and b = {20, 30, 40} using Python.