
  There are a large number of set operations,
including union ( ), intersection (& ),
difference ( ), symmetric difference (^ ).
These are unusual operations, so we'll look at them in some detail. In
addition to this operator notation, there are method functions which do
the same things. We'll look at the method function versions
below. We'll use the following two set s to show
these operators. >>>
fib=set( (1,1,2,3,5,8,13) )
>>>
prime=set( (2,3,5,7,11,13) )
Union, 
The resulting set has elements from
both source set s. An element is in the
result if it is one set
or
the other. >>>
fib  prime
set([1, 2, 3, 5, 7, 8, 11, 13])
Intersection, &
The resulting set has elements that
are common to both source set s. An element
is in the result if it is in one set
and
the other. >>>
fib & prime
set([2, 3, 5, 13])
Difference, 
The resulting set has elements of the
lefthand set with all elements from the
righthand set removed. An element will be
in the result if it is in the lefthand set
and not in the righthand set . >>> fib  prime
set([8, 1])
>>> prime  fib
set([11, 7])
Symmetric Difference, ^
The resulting set has elements which
are unique to each set . An element will be
in the result set if either it is in the
lefthand set and not in the righthand
set or it is in the righthand
set and not in the lefthand
set . Whew! >>>
fib ^ prime
set([8, 1, 11, 7])
 
 
