# Create two sets
setA = {11, 12, 13}
setB = {23, 24, 25}
# Perform set operations
print("Set 1:", setA)
print("Set 2:", setB)
print("Union:", setA.union(setB))
print("Intersection:", setA.intersection(setB))
print("Difference (setA - setB):", setA.difference(setB))
# Add and remove elements from a set
setA.add(34)
print("Set 1 after adding 34:", setA)
setA.remove(12)
print("Set 1 after removing 45:", setA)
No comments:
Post a Comment