-
-
Save nickyfoto/d4459c51b5dfe1b02018777c6b39dc30 to your computer and use it in GitHub Desktop.
Python set operation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://www.geeksforgeeks.org/python-set-operations-union-intersection-difference-symmetric-difference/ | |
A = {0, 2, 4, 6, 8} | |
B = {1, 2, 3, 4, 5} | |
# union | |
print("Union :", A | B) | |
# intersection | |
print("Intersection :", A & B) | |
# difference | |
print("Difference A - B:", A - B) | |
print("Difference B - A:", B - A) | |
# symmetric difference | |
print("Symmetric difference :", A ^ B) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment