We're going to start diving in into functions. Let's see a little bit the anatomy of a function and the syntax of a function. Here we have it. We're going to start a function as you can see here, we will start with the keyword D-E-F, DEF. We're defining a function, we're going to give it a name. In this case, as you can see, we're using the keyword sum, and then we open parentheses. Within the parentheses we're going to specify what we would call the parameters or the arguments of the function. These are going to be variables, so variables that will be used within the function to execute a particular task. In this case we're seeing number 1 and number 2. As we go into the function, you will see there's something that is quite invisible here, but it's the indentation. Everything that has been indented, meaning that we have a tab distance from the line where we start the definition means that exist within the function. Other programming languages actually use a curly bracket kind of separator to identify what belongs to the function. But within Python, we are actually using indentation, meaning that this distance is important to identify what belongs to the function. Let's read the first line. The first line says print number 1, and that's a string, meaning that it's a text. Then comma number 1. The variable that is obtained from the argument or the parameter print number 2 and then the number 2 variable. Then the addition, the expression is addition equals sum1 plus sum2 and return it to keyword that allows the function once it's executed, to create a new value and return that value wherever we're using it. This might all sound a bit confusing, we're going to see an example of this code together when we're going to be breaking this down. Most perhaps concerning thing here might be like, well where is the data really like? I don't see at any point here any information, actual numbers that I'm using to do this addition. But we have to assume that once the function gets executed, meaning that at some other point in the program, we're going to call the function. We're going to execute that function at that point, instead of providing variables as we're doing here, we will provide actual data. The function is using a placeholder, this number 1, and number 2 are variables that operate as placeholders to do an operation. But that information will be provided once we execute the function. Let's see how we would execute that function. Here's the version of that, much simpler, certainly, the execution of the function is the condensed version of that. We use the keyword that we identify as the name of the function, in this case some. We provide the argument. Here we're actually providing a five comma and eight which will represent number 1 and number 2 in the function. Together with getting a print into the console, we will get the return result of 13. We can actually use this sum function with different arguments, with different values, and executed many times within our code without having to repeat the definition of the function. Let me just go back to the previous slide. As you can see here, this is the definition of the function, and the execution of the function takes this more succinct smaller form. One small caveat is that within Python, and specifically also within the processing environment, which is what we're working on, there are already some inbuilt functions. Things that if you basically you type this word, it would switch color within the editor and we will be able to identify that there is a function associated with that keyword. You might have to avoid some of these keywords, and if you see again the text change in color, that means that maybe there's something associated with that, that could be a function. Many times something like the function float or function int, which are functions specifically constructed for you to convert data into those specific variable types are variables that are in-built into the language. The length of a list ways of sorting information. A series of functions that we will be learning gradually as we go within this course. But for now you have to know that there's some keywords that are already in built into the language. Let's jump into the code. Here we go. Let's write header. We're going to define our function and let's just print_sum. I'm going to call this function slightly different of what we saw in the example before. I'm going to call it the print_sum so it'll print the result of an addition operation. Let's open parentheses to provide arguments here or the parameters that are part of the function that ultimately will be the argument, so x and y. Notice that I'm going to use the column here, this is a keyword. When I use the column, you see if I press "Enter", the software automatically understands that I'm within the function. The indentation that we were just discussing is actually automatically calculated for us, we don't have to be pressing "Space" many times. If for whatever reason we press "Delete" and we move back from that indentation, we can press "Tab" again and we will be at the right indentation that is expected to be for this function to work. Let's do a few print commands. Let's print input one. When you can print a string, and let's add to that string. This is maybe a little bit strange because we're actually adding a string to a text. We're adding a number. If we add a number, we will have a problem. We can add strings together by adding two pieces of text, and we will end up with the concatenation or joining those texts together. In order to do that, we have to convert our x variable and we do that with a function called STR(x). We're converting the x value, which will most likely be an integer. We're expecting it to be an integer. We're going to convert it into a string or we're going to make sure that it's a string and that is the print command number 1. Let's do another one of those, and you can see we're still within the indentation of the function so that means that a series of lines will be executed every time that we execute the function. In this case, input number 2. I'm just copy-pasting the line because it's not necessary that I write those lines over and over again. I'm just going to change the x for y. Similarly, we will have two print commands. I want to make sure what is input one, what is input two, and then I also want to calculate the summation or the addition between x and y and finally, do a final print. Once more I'm going to copy-paste that line and this time, let's just delete all this here and type result. The result we're going to convert into a string value of some expression. That's great. We actually finished the function. We have completed our program. Let's press "Play", and you'll see that, well, nothing happens. What's wrong here? What's going on? As we just described, this definition of a function will not necessarily be executed unless we implement or execute the function. In order to do this, we have to use the name of the function. We're going to that here outside the indentation. Let's make sure that we're doing it starting from the very edge here. Open parentheses. Here, we're going to provide information, so 2,3, so this will represent x, and three will represent y. We're executing the function just with this execution. Let's see. What do we get? We could try to expand this area here and we get input one, it's two, input two is three, and the result is five. Can I call this function once more? Well, it's executed maybe another time with 6,20. As you can see sequentially, we have the print for the first execution of the function, the print for the second execution of the function. Again, this is what gives us the foundation of modularity. We do not have to repeat this piece of code. This is a function that now we can use in many places in our program. If we feel that there's a particular part of code that we are needing over and over again, it might be worth considering making a function out of it. I hope that's clear and we're going to continue using functions along the way with this class. But I'll see you in the next lesson.