Skip to content

Instantly share code, notes, and snippets.

@yatakeke
Last active November 29, 2019 02:11
Show Gist options
  • Save yatakeke/fc1b2db36a0530c463d7c8787f9c71e3 to your computer and use it in GitHub Desktop.
Save yatakeke/fc1b2db36a0530c463d7c8787f9c71e3 to your computer and use it in GitHub Desktop.
s = {1,2,3}
s.add(4)
print(s)
# {1,2,3,4}
s.remove(3)
print(s)
# {1,2,4}
s1 = {1,2,3}
s2 = {2,3,4}
s_union = s1 | s2
s_union = s1.union(s2)
print(s_union)
# {1,2,3,4}
s_union = s1.union(s2, [5,6])
print(s_union)
# {1,2,3,4,5,6}
s_intersection = s1 & s2
s_intersection = s1.intersection(s2)
print(s_intersection)
# {2,3}
s_difference = s1 - s2
# {1}
s_symmetric_difference = s1 ^ s2
# {1,4}
# issubset()
# TBD
# isupperset()
# TBD
# isdijoint()
# TBD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment