<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Chapter 7 - Sets
This chapter will introduce a different kind of container
Step1:  Curly brackets surround sets, and commas separate the elements in the set
A set can be empty (use set() to create it)
Sets do not allow duplicates
sets are unordered (the order in which you add items is not important)
A set can only contain immutable objects (for now that means only strings and integers can be added)
A set can not contain mutable objects, hence no lists or sets
Please note that sets do not allow duplicates. In the example below, the integer 1 will only be present once in the set.
Step2:  Please note that sets are unordered. This means that it can occur that if you print a set, it looks different than how you created it
Step3:  This also means that you can check if two sets are the same even if you don't know the order in which items were put in
Step4:  Please note that sets can only contain immutable objects. Hence the following examples will work, since we are adding immutable objects
Step5:  But the following example will result in an error, since we are trying to create a set with a mutable object
Step6:  2. How to add items to a set
The most common way of adding an item to a set is by using the add method. The add method has one positional parameter, namely what you are going to add to the set, and it returns None.
Step7:  3. How to extract/inspect items in a set
When you use sets, you usually want to compare the elements of different sets, for instance, to determine how much overlap there is or how many of the items in set1 are not members of set2. Sets can be used to carry out mathematical set operations like union, intersection, difference, and symmetric difference. Please take a look at this website if you prefer a more visual and more complete explanation. 
You can ask Python to show you all the set methods by using dir. All the methods that do not start with '__' are relevant for you.
Step8:  You observe that there are many methods defined for sets! Here we explain the two most common methods. We start with the union method.
Step9:  Python shows dots (...) for the parameters of the union method. Based on the docstring, we learn that we can provide any number of sets, and Python will return the union of them.
Step10:  The intersection method has works in a similar manner as the union method, but returns a new set containing only the intersection of the sets.
Step11:  Since sets are unordered, you can not use an index to extract an element from a set.
Step12:  4. Using built-in functions on sets
The same range of functions that operate on lists also work with sets. We can easily get some simple calculations done with these functions
Step13:  5. An overview of set operations
There are many more operations which we can perform on sets. Here is an overview of some of them.
In order to get used to them, please call the help function on each of them (e.g., help(set.union)). This will give you the information about the positional parameters, keyword parameters, and what is returned by the method.
Step14:  Before diving into some exercises, you may want to the dir built-in function again to see an overview of all set methods
Step15:  Exercises
Exercise 1
<ASSISTANT_TASK:>
Python Code:
a_set = {1, 2, 3}
a_set
empty_set = set() # you have to use set() to create an empty set! (we will see why later)
print(empty_set)
Explanation: Chapter 7 - Sets
This chapter will introduce a different kind of container: sets. Sets are unordered lists with no duplicate entries. You might wonder why we need different types of containers. We will postpone that discussion until chapter 8.
At the end of this chapter, you will be able to:
* create a set
* add items to a set
* extract/inspect items in a set
If you want to learn more about these topics, you might find the following links useful:
* Python documentation
* A tutorial on sets
If you have questions about this chapter, please contact us (cltl.python.course@gmail.com).
1. How to create a set
It's quite simple to create a set.
End of explanation
a_set = {1, 2, 1, 1}
print(a_set)
Explanation: Curly brackets surround sets, and commas separate the elements in the set
A set can be empty (use set() to create it)
Sets do not allow duplicates
sets are unordered (the order in which you add items is not important)
A set can only contain immutable objects (for now that means only strings and integers can be added)
A set can not contain mutable objects, hence no lists or sets
Please note that sets do not allow duplicates. In the example below, the integer 1 will only be present once in the set.
End of explanation
a_set = {1, 3, 2}
print(a_set)
Explanation: Please note that sets are unordered. This means that it can occur that if you print a set, it looks different than how you created it
End of explanation
{1, 2, 3} == {2, 3, 1}
Explanation: This also means that you can check if two sets are the same even if you don't know the order in which items were put in:
End of explanation
a_set = {1, 'a'}
print(a_set)
Explanation: Please note that sets can only contain immutable objects. Hence the following examples will work, since we are adding immutable objects
End of explanation
a_set = {1, []}
Explanation: But the following example will result in an error, since we are trying to create a set with a mutable object
End of explanation
a_set = set()
a_set.add(1)
print(a_set)
a_set = set()
a_set = a_set.add(1)
print(a_set)
Explanation: 2. How to add items to a set
The most common way of adding an item to a set is by using the add method. The add method has one positional parameter, namely what you are going to add to the set, and it returns None.
End of explanation
dir(set)
Explanation: 3. How to extract/inspect items in a set
When you use sets, you usually want to compare the elements of different sets, for instance, to determine how much overlap there is or how many of the items in set1 are not members of set2. Sets can be used to carry out mathematical set operations like union, intersection, difference, and symmetric difference. Please take a look at this website if you prefer a more visual and more complete explanation. 
You can ask Python to show you all the set methods by using dir. All the methods that do not start with '__' are relevant for you.
End of explanation
help(set.union)
Explanation: You observe that there are many methods defined for sets! Here we explain the two most common methods. We start with the union method.
End of explanation
set1 = {1, 2, 3, 4, 5}
set2 = {4, 5, 6, 7, 8}
the_union = set1.union(set2)
print(the_union)
set1 = {1, 2, 3, 4, 5}
set2 = {4, 5, 6, 7, 8}
set3 = {5, 6, 7, 8, 9}
the_union = set1.union(set2, set3)
print(the_union)
Explanation: Python shows dots (...) for the parameters of the union method. Based on the docstring, we learn that we can provide any number of sets, and Python will return the union of them.
End of explanation
help(set.intersection)
set1 = {1, 2, 3, 4, 5}
set2 = {4, 5, 6, 7, 8}
the_intersection = set1.intersection(set2)
print(the_intersection)
set1 = {1, 2, 3, 4, 5}
set2 = {4, 5, 6, 7, 8}
set3 = {5, 8, 9, 10}
the_intersection = set1.intersection(set2, set3)
print(the_intersection)
Explanation: The intersection method has works in a similar manner as the union method, but returns a new set containing only the intersection of the sets.
End of explanation
a_set = set()
a_set.add(1)
a_set.add(2)
a_set[0]
Explanation: Since sets are unordered, you can not use an index to extract an element from a set.
End of explanation
nums = {3, 41, 12, 9, 74, 15}
print(len(nums)) # number of items in a set
print(max(nums)) # highest value in a set
print(min(nums)) # lowest value in a set
print(sum(nums)) # sum of all values in a set
Explanation: 4. Using built-in functions on sets
The same range of functions that operate on lists also work with sets. We can easily get some simple calculations done with these functions:
End of explanation
set_a = {1, 2, 3}
set_b = {4, 5, 6}
an_element = 4
print(set_a)
#do some operations 
set_a.add(an_element)  # Add an_element to set_a
print(set_a)
set_a.update(set_b)     # Add the elements of set_b to set_a
print(set_a)
set_a.pop()         # Remove and return an arbitrary set element. How does this compare to the list method pop?
print(set_a)
set_a.remove(an_element)     # Remove an_element from set_a
print(set_a)
Explanation: 5. An overview of set operations
There are many more operations which we can perform on sets. Here is an overview of some of them.
In order to get used to them, please call the help function on each of them (e.g., help(set.union)). This will give you the information about the positional parameters, keyword parameters, and what is returned by the method.
End of explanation
dir(set)
Explanation: Before diving into some exercises, you may want to the dir built-in function again to see an overview of all set methods:
End of explanation
set_1 = {'just', 'some', 'words'}
set_2 = {'some', 'other', 'words'}
# your code here
Explanation: Exercises
Exercise 1:
Please create an empty set and use the add method to add four items to it: 'a', 'set', 'is', 'born'
Exercise 2:
Please use a built-in method to count how many items your set has
Exercise 3:
How would you remove one item from the set?
Exercise 4:
Please check which items are in both sets:
End of explanation
<END_TASK>