This program demonstrates the use of set intersections in Python. Sets are unordered collections of unique elements, and set intersections are used to find the common elements between two sets.
In this example, both methods produce the same result, which is the set {40, 20}, representing the common elements between the two sets a and b.
a = {30,40,70,20} b = {20,50,60,40} print("Original set Values :") print(a) print(b) print("\nIntersection of two Sets:") #First Method c = a & b print(c) #Second Method d=a.intersection(b) print(d)
Original set Values : {40, 20, 70, 30} {40, 50, 20, 60} Intersection of two Sets: {40, 20} {40, 20}
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions