This article demonstrates various operations on Input: A = {0, 2, 4, 6, 8} B = {1, 2, 3, 4, 5} Output: Union: [0, 1, 2, 3, 4, 5, 6, 8] Intersection: [2, 4] Difference: [8, 0, 6] Symmetric difference: [0, 1, 3, 5, 6, 8] In Python below, fast operands can be used for various operations. | for union.
& amp; for intersection.
- for difference
^ for symmetric difference
|
Exit:
(’Union:’, set ([0, 1, 2, 3, 4, 5, 6, 8]) ) (’Intersection:’, set ([2, 4])) (’Difference:’, set ([8, 0, 6])) (’Symmetric difference:’, set ([0, 1, 3, 5 , 6, 8]))