This is a python program to illustrate different set of operations. tested in python version 3.x
Output:
Union of E and N is {0, 1, 2, 3, 4, 5, 6, 8}
Interaction of E and N is {2, 4}
Difference of E and N is {8, 0, 6}
Symmetric difference of E and N is {0, 1, 3, 5, 6, 8}
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Python program to illustrate different set of operations # set operations like in mathematics # define three sets E = {0,2,4,6,8}; N = {1,2,3,4,5}; # set union print("Union of E and N is",E|N) # set interaction print("Interaction of E and N is",E&N) # set difference print("Difference of E and N is", E-N) # set symmetric difference print("Symmetric difference of E and N is", E^N) |
Output:
Union of E and N is {0, 1, 2, 3, 4, 5, 6, 8}
Interaction of E and N is {2, 4}
Difference of E and N is {8, 0, 6}
Symmetric difference of E and N is {0, 1, 3, 5, 6, 8}
Comments
Post a Comment