Sets are used to store collections of data / items which is unordered and unindexed.
Program Code
Input and Output:Output:
Creating two setsy
Set1 = set()
Adding elements to set
Set2 = {3, 4, 5, 6, 7}
Union of sets
Union of Set1 & Set2: Set3 = {2, 3, 4, 5, 6, 7}
Intersection of sets
Intersection of Set1 & Set2: Set4 = {3}
Checking relation between sets
Set1 is same as Set2
Diference between set1 and set2
Set1 - Set2 = set5 = {2}
check if for sets are disjoint or not
sets are disjoint
Removing all the values of set5
Set5 = set()