A = {1, 2, 3}
B = {3, 4, 5}
Notation | Operation | Python | Result |
A∩B | Intersection | print(A & B) |
{ 3 } |
A∪B | Union | print(A | B) |
{ 1, 2, 3, 4, 5 } |
A-B | Difference (or relative complement) | print(A – B) |
{ 1, 2 } |
B-A | Difference (or relative complement) | print(B – A) |
{ 4, 5 } |
A∆B | Symmetric difference | print(a ^ b) |
{ 1, 2, 4, 5 } |