 In this video, we are going to learn about operators. So let's first start a new notebook file and rename it into operators. And operators are generically speaking symbols that have a special meaning to the Python interpreter. So when Python sees them, it does something accordingly. So a very trivial example is to use the plus symbol. For example, we could say 77 plus 13 and we get back to number 90. And similarly, if we want to subtract from the number 101, the number 93, then this of course also works, okay? So plus or minus, they just work as if we are using a calculator here. Any operator that takes two operands, one on the left and the other on the right-hand side, is what we call a so-called binary operator. Binary operator. So that means it takes two operands. Plus and minus can also be used with only one operand. So they are also of a second prete, so to say. So let's go ahead and just illustrate the point. We could say plus one, could also say minus one, and that also works. And any operator that takes or also works with only one operand is what we would refer to as a so-called unary operator, okay? So this is a rather trivial, but it's a good concept to know, especially those technical terms. So let's look at a couple of other operators that we haven't seen before. In particular, multiplication, okay? So multiplication in Python works with the star operator or sometimes also called the asterix operator. So let's say, if I want to go ahead and multiply the number two by 21, I would simply write two star 21, and this gives me back the number 42. Okay, so this is multiplication. And the opposite of that we have seen before in the last video division. So there are three kinds of divisions and just to review that rather quickly, if I divide the number seven with the single forward slash by two, I get back to number 3.5. If I do so with the double forward slash, then I get back to integer three. And if I do so with the percentage symbol, this is called the model operator. Then I get back the rest of the division, which is the number one, okay? So let's summarize, we have three kinds of division. So the first one would be the single slash. This is the, let's simply call it the common division. Operator. Then we have the double forward slash. We call that the so-called integer division operator. And as we saw before, the model operator, we call that the model operator, model division operator. And this concerns kind of like rest division in simple terms. Okay, so these are the three different kinds of division and they and also the multiplication, they are all examples of binary operators. Okay, let's go ahead. What else can we do? So a concept that is very similar to multiplication and extension, so to say, of multiplication would be taking something to the power of some other number. So let's say, if I wanted to take the number two to the power of three, which is two times two times two, then I'm going to write that with the double asterisks. So two to the power of three would be eight. And here is a little caveat. So you should not confuse that with another operator, which looks like this. This operator here looks like exponentiation and it is actually exponentiation in a couple of other programming languages, but not so in Python. In Python, this is an operator that concerns very low level operation in memory that can also be used to do some sort of arithmetic. However, it's not the arithmetic we know from high school. So I will rather just skip that for now, but let's put a warning here, beware of that. Okay, so don't confuse that with the double asterisks here. Okay, so these are a couple of common arithmetic operators. And now regarding the two division kinds, instead of using an operator, we could have used a function. There is a built-in function called diffmod. And we're going to call it with two inputs, the first one being let's say seven, the second one being two. So the first number is going to be divided by the second one. And what this mod does is it gives me back a pair of numbers. So it takes a pair of numbers and it gives me back a pair of numbers. And the first number, so the first result I get back is basically just seven double slash divided by two and the second number would be the result of the modular division. And the diffmod function does both operations in one step. However, and that is why I put it here, this is an example of a function. So don't confuse the idea of calling a function with using an operator, okay? So sometimes in code, you can solve a problem by using some function, by executing some function. Sometimes you do that by using some operators, but syntactically speaking, an operator and a function are totally different things and this is just here an example to illustrate this point, okay? But now let's come to a different topic that is a bit more important and this regards the so-called order of precedence and that is the order in which operators are evaluated. So let's say I go ahead and I write two times two and I take this to the power of three. Now we can read that in two different ways. We could say, we read it from left to right, we could say we multiply two by two, this gives me four and then I take four to the power of three, okay? Or we could say, well, exponentiation should have higher binding power, at least in math, this is the case. So we should take two to the power of three, which is eight, and then we should multiply the resulting eight with the two to obtain 16. So let's see what Python does and Python indeed gives us back 16. So Python, in many cases, simply sticks to the mathematical rules, okay? And this is a good design choice by the core developers of Python because otherwise this would be very confusing to read, okay? So Python executes the exponentiation higher than the multiplication. So how does Python do that in particular? Well, it uses behind the scenes the so-called PEMPTAS rule. So PEMPTAS means first go to parentheses, then the exponentiation, then multiplication and division, and then addition and subtraction, just like in math, okay? So let's look at the P, the parentheses. So we could also go ahead and we could have written this example just like this, two times in parentheses, two to the power of three. This gives me, of course, the same result, but now we are communicating in a clearer way what the expression here means. And if we go ahead and put the parentheses, not around the two to the power of three, but around the two times two here, and then take the result to the power of three, we will, of course, get a different result, 64, okay? This is just to illustrate the point. So you can put parentheses whenever you want. Sometimes they're not needed, but even then, more often than not, you can simply put them there just to communicate clearer what you want so that it is easier to read the code later on and grasp what an expression really means. If you have, if you need to apply several pairs of parentheses, you can, of course, also nest them. So you could go ahead and say two times, and let's put another pair of parentheses, let's say one plus one, and take the result to the power of three. This gives, of course, also 64, okay? So then the parentheses I evaluated from the inside out here, so to speak, okay? Just like in math. So that is some basics regarding operators, so symbols that have a special meaning, but now comes something that not every programming language just supports, but Python does. And this is a concept that we will refer to as operator overloading. And what that means is, an operator may have a different meaning in a different context. And what the term context means, I will specify a bit clearer in a bit. So let's first look at an example. So far we have only worked with numbers. So let's go ahead and work with text data. So how do we do that? Well, what we could do is we have seen this briefly before. We could use a pair of double quotes, and inside double quotes, we could write some text. So for example, random text. If I execute this code file, I get back a object which models textual data. Now you may be confused because Python gives us back single quotes here. So this is due to the fact that double quotes and single quotes are synonyms, okay? They can be perfectly substituted for each other in most cases. We will look into the textual data and how that works in detail in a later video, but for now just understand that double quotes and single quotes can be used as synonyms. And recently the Python community tended to use double quotes over single quotes for readability purposes, but again, this is just a convention. So syntactically, there is no difference. Anyways, this is now an example of an object in the memory that models textual data. And now what can we do with textual data? Well, interestingly, we can multiply this. So I could say three times the text here. And then what I get is I get one text object that contains three copies, so to say, or three repetitions of the same text as before. And because I do not end here with a space, that is why I don't see a space here as well. So maybe I can put a space here and then we have an additional space in between here as well. But the important idea is I can multiply text, okay? And what it does is it repeats the text object several times and there is a name for that. This is called concatenation. And we can translate that into maybe putting this simply call it things for now together, okay? So in other words, take a thing, in this case, a text object and put it together several times. That is what concatenation means. And this not only works for text data, we could also go ahead and create a list object. So using the brackets here, I create a list. And I put in there the numbers one, two, and three. So this is a list object. And I could also multiply the list. Let's multiply it from the right-hand side with the number 10. And this will give me back a big list object with the numbers one, two, three repeated 10 times. So maybe I should just choose two to make it a bit more readable here. But we see that the numbers one, two, three are repeated two times here, okay? And this is also the concept of concatenation. We are concatenating two lists, so to say, together to obtain one larger list. Okay, and now we can understand what I mean with the term context here. So context basically means the types, the so-called data types of the operands. Okay, so above, when I do multiplication with numbers, I just do multiplication. If I use the star operator with text and a number, then we do concatenation, okay? So if I multiply two numbers, it's multiplication. If I multiply a number and text, then I have concatenation. It's a different meaning. The operator has a different meaning. Given a different context, and the context again means that the data type of the involved operands is different. Okay, so that is the idea of operator overloading. And this not only works for the multiplication operator, but it would also work for the addition operator. So maybe in an easy example, I could say hello, and let's add this together with maybe single quotes, world. And I get back one word saying hello world. So I can also add together two text objects. It's also perfectly doable here. Okay, so this is a brief introduction on what operators are. Again, they are special symbols that make Python do certain things. And you have learned a couple of rules and in future chapters and videos, we will learn more operators and also we will look into further examples of the idea of operator overloading. So familiar operators doing something different given yet another context, okay? So this concludes this discussion of operators.