Join Sets Using union() :

set1 = {"a", "b", "c"}
set2 = {1, 2, 3}
set3 = set1.union(set2)  # Create new set with all elements
print(set3)

Output :

{'a', 'b', 'c', 1, 2, 3}

Keep Only Duplicates Using intersection_update() :

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
x.intersection_update(y)
print(x)  # Only "apple" will remain

Output :

{'apple'}

Get Intersection as New Set :

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.intersection(y)
print(z)  # New set with common elements

Output :

{'apple'}

Keep Only Non-Matching Items Using symmetric_difference update() :

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
x.symmetric_difference_update(y)
print(x)  # Items not common to both sets

Output :

{'banana', 'google', 'cherry', 'microsoft'}

Get Symmetric Difference as New Set :

x = {"apple", "banana", "cherry"}
y = {"google", "microsoft", "apple"}
z = x.symmetric_difference(y)
print(z)  # New set with non-common items

Output :

{'banana', 'google', 'cherry', 'microsoft'}