See https://docs.python.org/2/library/sets.html for documentation, and other URLs below for examples

In :
X=set([1,2,3,4,5])
C=set(['Ithaca','Boston','Chicago'])
Stuff=set([1,'snow','Cornell','y'])
emptyset = set()
In :
1 in X
Out:
True
In :
1 not in C
Out:
True
In :
def is_even(x): return(x%2 == 0)   #x%2 is the remainder after division by 2
In :
is_even(4),is_even(21)
Out:
(True, False)
In :
len(X), len(C), len(Stuff), len(emptyset)  #cardinalities
Out:
(5, 3, 4, 0)
In :
Cp=set(['Ithaca','Chicago'])  #C' in notes
Xp=set(range(2,6))            #X' in notes
In :
Xp
Out:
{2, 3, 4, 5}
In :
A=set([1,2,3])
In :
X.isdisjoint(C), Cp.isdisjoint(C)
Out:
(True, False)
In :
Cp <= C, Cp.issubset(C)  #both mean 'is subset'
Out:
(True, True)
In :
C<=C, C<C  #test for proper and improper subsets
Out:
(True, False)
In :
Cp != C, Cp == C  #tests for set equality
Out:
(True, False)
In :
def powerset(S):
R=[[]]
for s in S: R += [T+[s] for T in R]
return set(map(tuple,R))
In :
powerset(A)
Out:
{(), (1,), (1, 2), (1, 2, 3), (1, 3), (2,), (2, 3), (3,)}
In :
sorted(powerset(A),key=len)  #subsets sorted by cardinality
Out:
[(), (1,), (2,), (3,), (1, 2), (1, 3), (2, 3), (1, 2, 3)]
In :
X | Stuff  # union
Out:
{1, 2, 3, 4, 5, 'Cornell', 'snow', 'y'}
In :
C | emptyset  #union
Out:
{'Boston', 'Chicago', 'Ithaca'}
In :
A | X  #union
Out:
{1, 2, 3, 4, 5}
In :
(A|X) == X, A.union(X) == X   #test whether A union X is equal to X
Out:
(True, True)
In :
X & Stuff # intersection
Out:
{1}
In :
X.intersection(Stuff)  #same thing
Out:
{1}
In :
C & emptyset
Out:
set()
In :
A & X
Out:
{1, 2, 3}
In :
X-Stuff  #set difference
Out:
{2, 3, 4, 5}
In :
C-emptyset
Out:
{'Boston', 'Chicago', 'Ithaca'}
In :
X^Stuff  #symmetric difference
Out:
{2, 3, 4, 5, 'Cornell', 'snow', 'y'}
In :
C^emptyset
Out:
{'Boston', 'Chicago', 'Ithaca'}
In :
X^A
Out:
{4, 5}
In :
A
Out:
{1, 2, 3}
In :
def cartesian_product(S1,S2): return {(a,b) for a in list(S1) for b in list(S2)}
In :
cartesian_product(A,A)
Out:
{(1, 1), (1, 2), (1, 3), (2, 1), (2, 2), (2, 3), (3, 1), (3, 2), (3, 3)}

The following examples are from some of the online docs

In :
b = set('alacazam')
a  # unique letters in a
Out:
{'a', 'b', 'c', 'd', 'r'}
In :
basket = ['apple', 'orange', 'apple', 'pear', 'orange', 'banana']
'orange' in fruit, 'crabgrass' in fruit
Out:
(True, False)
In :
{x for x in 'abracadabra' if x not in 'abc'}
Out:
{'d', 'r'}
In :
a-b # letters in a but not in b
Out:
{'b', 'd', 'r'}
In :
a|b  # letters in either a or b
Out:
{'a', 'b', 'c', 'd', 'l', 'm', 'r', 'z'}
In :
a&b # letters in both a and b
Out:
{'a', 'c'}
In :
a^b # letters in a or b but not both
Out:
{'b', 'd', 'l', 'm', 'r', 'z'}
In [ ]: