'''
Created on Oct 7, 2014

@author: Susan
'''

#create and print a list
colorList = ['red', 'blue', 'red', 'red', 'green']
print "list of colors", colorList

# now create a set from the list, what happens
# note the SIZE is different, only unique elements in a set
colorSet = set(colorList)
print "set of same colors", colorSet
print type(colorSet)
smallList = list(colorSet)
print smallList
print type(smallList)


#clear the set - now an empty set
colorSet.clear()
print colorSet

colorSet.add("yellow")
colorSet.add("red")
colorSet.add("blue")
colorSet.add("yellow")
colorSet.add("purple")

# note yellow appears in there only once
print len(colorSet)
print colorSet

# Note second command is useless, yellow already removed
colorSet.remove("yellow")
# this next line commented out gives an error since there is no yellow
#colorSet.remove("yellow")  # this gives an error!
print colorSet

UScolors = set(["red", "white", "blue"])
dukeColors = set(["blue", "white"])

#union two sets - two different ways
print "union", dukeColors.union(UScolors)
print "union", dukeColors | UScolors

#intersection two sets
print "intersection", dukeColors.intersection(UScolors)
print "intersection", dukeColors & UScolors
# difference
print "difference", dukeColors.difference(UScolors)
print "difference", dukeColors - UScolors
print "difference", UScolors - dukeColors

print "Symmetric difference", dukeColors ^ UScolors
print "Symmetric difference", UScolors ^ dukeColors



colorList = ['red', 'blue', 'red', 'red', 'green']
colorSet = set(colorList)
smallList = list(colorSet)
colorSet.clear()
colorSet.add("yellow")
colorSet.add("red")
colorSet.add("blue")
colorSet.add("yellow")
colorSet.add("purple")
colorSet.remove("yellow")


# note yellow appears in there only once
print len(colorSet)
print colorSet

UScolors = set(["red", "white", "blue"])
dukeColors = set(["blue", "white"])
print dukeColors.union(UScolors)
print dukeColors | UScolors
print dukeColors.intersection(UScolors)
print dukeColors & UScolors
print dukeColors.difference(UScolors)
print dukeColors - UScolors
print UScolors - dukeColors
print dukeColors ^ UScolors
print UScolors ^ dukeColors
