<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 5 - Core concepts of containers
In the next chapters, we will introduce the most important containers in the Python language
Step1:  2. Understanding class methods
Let's look at some string method examples from the last chapters
Step2:  In all of the examples above, a string method is called, e.g., upper or count.
However, they differ regarding their arguments
Step3:  The method documentation contains three parts
Step4:  It worked! We've called the string method by only providing a value for the positional parameters. However, what if we are not happy with the provided default value, can we override it?
Let's try this. The keyword parameter count allows us to indicate how many times to replace a substring. Let's try to only replace 'r' to 'c' one time.
Step5:  Yes! We've provided a value for count, e.g., 1, and now 'r' is only replaced once with 'c'. Luckily, the 'r' in 'are' has not been replaced.
We will now move on to the string method split.
Step6:  Let's go through the parameters of the string method split
Step7:  And that is correct! Of course, we can specify a value for the keyword parameters. We provide the a space ' ' for sep and 2 for maxsplit.
Step8:  Please note that we have splitted the string on a space ' ' two times.
Try and play with with the split function
Step9:  For the answer, we need to go back to the function parameters
Step10:  This does not.
Step11:  Summary
Step12:  Exercise 2
<ASSISTANT_TASK:>
Python Code:
# Some examples (you do not have to remember this now):
a_list = [1,2,3, "let's", "use", "containers"]
a_tuple = (1, 2, 3, "let's", "use", "containers")
a_set = {1, 2, 3, "let's", "use", "containers"}
a_dict = {1:"let's",  2:"use", 3: "containers"}
#print(a_list)
#print(a_tuple)
#print(a_set)
#print(a_dict)
Explanation: Chapter 5 - Core concepts of containers
In the next chapters, we will introduce the most important containers in the Python language: lists, sets, tuples, and dictionaries. However, before we introduce them, it's important that we present some things that they all share, which is the goal of this chapter.
At the end of this chapter, you will be able to understand the following concepts:
* positional parameters
* keyword parameters
* positional-only arguments
* mutability
If you want to learn more about these topics, you might find the following links useful:
* the Python glossary: please look for the terms immutable, parameter, and argument
* What is the difference between arguments and parameters?
If you have questions about this chapter, please contact us (cltl.python.course@gmail.com).
1. Containers
When working with data, we use different Python objects (which we summarize containers) to order data in a way that is convenient for the task we are trying to solve. Each of the following container types has different advantages for storing and accessing data (which you will learn about in the following chapters):
lists
tuples
sets
dictionaries
Each container type can be manipulated using different methods and functions, for instance, allowing us to add, access, or remove data. It is important that you understand those.
End of explanation
a_string = 'hello world'
print('example 1. upper method:', a_string.upper())
print('example 2. count method:', a_string.count('l'))
print('example 3. replace method:', a_string.replace('l', 'b'))
print('example 4. split method:', a_string.split())
print('example 5. split method:', a_string.split(sep='o'))
Explanation: 2. Understanding class methods
Let's look at some string method examples from the last chapters:
End of explanation
help(str.replace)
Explanation: In all of the examples above, a string method is called, e.g., upper or count.
However, they differ regarding their arguments:
* There are no arguments in the case of upper, i.e., no arguments between the round brackets.
* for count, we specify a string 'l' as an argument
* for replace, we specify two strings as arguments
* for split, we can specify an argument, but we do not have to
This might look a bit confusing. Luckily Python has a built-in function help, which provides us insight into how to use each method. We will guide you through understanding the information provided for the string method replace.
End of explanation
a_string = 'rats are the best.'
result = a_string.replace('r', 'c') 
print(result)
Explanation: The method documentation contains three parts:
1. data structure: sentence starting with Help on. This simply indicates the data structure for which information is shown, which is a method in this case.
2. parameters: information about the parameters of the method, i.e., replace(self, old, new, count=-1, /). This is the most important part of the documentation.
3. docstring: explanation about the method in free text
Let's go through the parameters of the string method replace:
* self: for now, the only thing to remember about self is that it tells you that replace is a method and that you should ignore it when calling the method!
* old: this is a positional parameter
* new: this is a positional parameter
* count=-1: this is a keyword parameter, meaning that it has a default value, i.e., -1
* / (forward slash): for now, please ignore, we will come back to this.
In the enumeration above, we've used the terms positional parameter and keyword parameter. What are they, and in what do they differ?
* Positional parameters are compulsory to call a method. Without them, you will not successfully call the method.
* Keyword parameters are optional. They have a default value, e.g., -1 in the case of count, and are optional.
Let's put this to the test! Since positional parameters are needed to call our method, we should be able to call the method by specifying a value for old and new, but not for count. The value for old is 'r', and the value for new is 'c'.
End of explanation
a_string = 'rats are the best.'
result = a_string.replace('r', 'c', 1) 
print(result)
Explanation: It worked! We've called the string method by only providing a value for the positional parameters. However, what if we are not happy with the provided default value, can we override it?
Let's try this. The keyword parameter count allows us to indicate how many times to replace a substring. Let's try to only replace 'r' to 'c' one time.
End of explanation
help(str.split)
Explanation: Yes! We've provided a value for count, e.g., 1, and now 'r' is only replaced once with 'c'. Luckily, the 'r' in 'are' has not been replaced.
We will now move on to the string method split.
End of explanation
a_string = 'USA Today has come out with a new survey: Apparently three out of four people make up 75 percent of the population.'
words = a_string.split()
print(words)
Explanation: Let's go through the parameters of the string method split:
* self: for now, the only thing to remember about self is that it tells you that replace is a method and that you should ignore it in calling the method!
* / (forward slash): for now, please ignore, we will come back to this.
* sep=None: this is a keyword parameter, meaning that it has a default value, i.e., None.
* maxsplit=-1: this is a keyword parameter, by which you can indicate how many times to split.
Since split has no positional parameters, we should be able to call the method without providing arguments.
End of explanation
a_string = 'USA Today has come out with a new survey: Apparently three out of four people make up 75 percent of the population.'
words = a_string.split(' ', 2)
print(words)
Explanation: And that is correct! Of course, we can specify a value for the keyword parameters. We provide the a space ' ' for sep and 2 for maxsplit.
End of explanation
a_string = 'USA Today has come out with a new survey: Apparently three out of four people make up 75 percent of the population.'
words = a_string.split(sep=' ', maxsplit=2)
print(words)
a_string = 'rats are the best.'
result = a_string.replace('r', 'c', count=1) 
Explanation: Please note that we have splitted the string on a space ' ' two times.
Try and play with with the split function: (e.g. how does split(' ') differ from split()?)
2.1 The forward slash
So far, we have not explained the forward slash in the parameters. Here, we highlight its importance to calling a method. We show two examples. The main question is the following: why is the first call successful, and why does the second call result in error?
End of explanation
a_string = 'rats are the best.'
result = a_string.replace('r', 'c', 1) 
print(result)
Explanation: For the answer, we need to go back to the function parameters:
* replace: replace(self, old, new, count=-1, /)
* split: split(self, /, sep=None, maxsplit=-1)
Please note that the difference is that count is to the left of the forward slash, and sep and maxsplit are to the right of the forward slash! We can call any parameter to the right of the forward slash using the name of the parameter. For any parameter to the left of the forward slash, we can only provide the value.
This does work:
End of explanation
a_string = 'rats are the best.'
result = a_string.replace('r', 'c', count=1) 
Explanation: This does not.
End of explanation
print(a_string.lower())
print(a_string.strip())
print(a_string.strip('an'))
print(a_string.partition('and'))
Explanation: Summary:
* ignore self
* positional parameters are mandatory to call a method
* keyword parameters are optional since they have a default value
* any parameter to the right of the forward slash, we can call using the name of the parameter. 
* any parameter to the left of the forward slash, we can only provide the value.
For those interested in understanding it in more detail, please check the link about positional-only arguments at the top of this notebook.
3. Mutability
Hopefully, it will become clear in the following chapters what we mean by mutability. For now, you can think of it in terms of 'can I change the data?'. Please remember the following categories for the subsequent chapters:
| immutable   | mutable | 
|-----------------|-------------|
|   integer       |  list       |
|   string        |  set        |
|     -           |  dictionary |
You have already seen a little bit about strings and immutability in Chapter 3. To change a string, we have to create a new one. In contrast, you will learn that many containers can be modified. 
Exercises
Please find some exercises about core concepts of python containers below. 
Exercise 1:
Use the help function to figure out what the string methods below are doing. Then analyze how many positional and keyword parameters are used in the following examples:
End of explanation
# your examples here
Explanation: Exercise 2:
Please illustrate the difference between positional and keyword parameters using the example of string methods. Feel free to use dir(str) and the help function for inspiration.
End of explanation
<END_TASK>