Skip to content

Instantly share code, notes, and snippets.

@gideondsouza
Created September 6, 2013 07:16
Show Gist options
  • Save gideondsouza/6460529 to your computer and use it in GitHub Desktop.
Save gideondsouza/6460529 to your computer and use it in GitHub Desktop.
Introducing a set
>>>
>>> S = {1,3} #a new set with two elements
>>> type(S) #what is the type of S?
<class 'set'>
>>> S1 = {3,4,5} #initialize two sets S1 and S2
>>> S2 = {3,6,7}
>>> S1 | S2 #this will give you a union of the two.
{3, 4, 5, 6, 7}
>>> #you can also use & for intersection, and ^ for xor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment