# Creating a Set using curly bracket notation
my_set = {"MONDAY", "TUESDAY", "WEDNESDAY"}

"""
Explanation: Sets
A Set is an unordered collection of unique and immutable objects. Sets can be heterogenous in composition. A set is it's own category of data structures, as is a sequence and a mapping. However, the set category in Python has one data structure, literally known as the set, while sequences in Python are strings, lists, tuples, etc. In this lecture, we will cover:
1. Initializing a Set
    &gt; Curly bracket notation
2. Access and Modifying a Set
3. Initialize a Set using set() function

Initializing a Set
We can initialize a set using curly bracket notation or the set() built-in function. In sets, all objects must be hashable types, like the key of a dictionary. This means that lists and dictionaries cannot be in a set, but objects like numbers and strings can be.
End of explanation
"""


my_set = {"Hello", 9.0, "foo", 19}

"""
Explanation: Sets can be heterogenous, as long as they are unique, too.
End of explanation
"""


# A set with non-unique elements?
my_set = {"Hello", "Hello", 9.0, 9.0}

"""
Explanation: Notice how all of the objects in the set we made are unique. What if we make a set like this?
End of explanation
"""


# A set with non-unique elements?
my_set = {"Hello", "Hello", 9.0, 9.0}
# Verifying that the set only considered each item once
print(my_set)

"""
Explanation: Fear not - no errors or exceptions are raised when adding items that already exist in a set, they are just considerd by the set once. While the cell does not accurately represent this, we can print and verify.
End of explanation
"""


# Create a Set of strings
yoz_set = {"Temple Run", "2048", "Fruit Ninja", "Crossy Road"}

"""
Explanation: Set Methods
The only built-in set function we need to use is discussed in the next section of this notebook. Let's take a look at set methods before we talk about the set() method.
1. add()
2. clear()
3. copy()
4. difference()
5. discard()
6. pop()
7. remove()

Let's begin by initializing a set with curly bracket notation, and then using these methods.
End of explanation
"""


# Add an object to our set
yoz_set.add("Blocky")
# Verify
print(yoz_set)

"""
Explanation: The add() method adds an item to a set (mutator).
End of explanation
"""


# Clear a Set
yoz_set.clear()
# Verify
print(yoz_set)

"""
Explanation: A call to clear() on a set deletes all of its objects.
End of explanation
"""


# Recreate yoz_set
yoz_set = {"Temple Run", "2048", "Fruit Ninja", "Crossy Road"}
# Copy and save the set
my_second_yoz_set = yoz_set.copy()
# Verify
print(my_second_yoz_set)

"""
Explanation: The copy() method returns a copy of the set object. It allows the programmer to quickly replicate the object distinctly (not object reference).
End of explanation
"""


# Create a set
my_set = {"woo", "foo"}
# Create another set
my_2_set = {"rsoos", "dja"}
# Difference
my_set.difference(my_2_set)

"""
Explanation: The difference() method returns the objects that make a set different from the implicit parameter.
implicit_set.difference(explicit_set)

Returns objects from the implicit_set that do not exist in the explicit set.
End of explanation
"""


# Create a Set
yoz_set = {"Temple Run", "2048", "Fruit Ninja", "Crossy Road"}
# Discard "Fruit Ninja"
yoz_set.discard("Fruit Ninja")
# Verify that "Fruit Ninja" is gone from set
print(yoz_set)

"""
Explanation: The discard(object) method removes an object from the set. If object is not in set, nothing is removed.
End of explanation
"""


# Create a Set
my_set = {"woo", "foo"}
# Pop an element
my_set.pop()
# verify something was removed
print(my_set)

"""
Explanation: The pop() removes and returns an arbitrary element from the set.
End of explanation
"""


# Create a Set
my_set = {"Chicago", "Tahalasee", "Houston"}
# Remove Houston from the set
my_set.remove("Houston")
# Verify Houston is gone
print(my_set)

# Try to remove Boston from the set (it doesn't exist)
my_set.remove("Boston")

"""
Explanation: The remove() method removes an object from a set. However, unlike the discard() method, it raises a KeyError if the element is not present.
End of explanation
"""


# Create a set with set()
x = set()

# Adding items to the set
x.add("Hello")
x.add(1)
x.add("River")
# Verify set() and add() work
print(x)

"""
Explanation: Set() Method
We can also use the set() built-in function to create a set. Set has two constructors:
set() - Creates an empty set object
set(iterable) - Creates a set from an iterable

If we create an empty set using set(), we use the built-in set methods to operate on it.
End of explanation
"""


