Sets

fruits = {"apple", "banana", "orange"}
fruits = {"apple", "banana", "orange"}
fruits.add("kiwi")
fruits.remove("banana")
print(fruits)  # Output: {"apple", "orange", "kiwi"}
{'kiwi', 'apple', 'orange'}
fruits = {"apple", "banana", "orange"}
print("banana" in fruits)  # Output: True
print("kiwi" in fruits)  # Output: False
True
False
set1 = {1, 2, 3}
set2 = {3, 4, 5}

union = set1.union(set2)
intersection = set1.intersection(set2)
difference = set1.difference(set2)

print(union)  # Output: {1, 2, 3, 4, 5}
print(intersection)  # Output: {3}
print(difference)  # Output: {1, 2}
{1, 2, 3, 4, 5}
{3}
{1, 2}