‫Welcome back.
‫Let's talk about a important term when it comes to programming, and that is operator precedence.
‫Now, what does that mean?
‫Again, we're using our knowledge from math class.
‫It's the idea that if I do 20 plus three times four, it means that different operators have precedence
‫over different ones.
‫That is, we multiply this first equals to 12 and then 20 gets added to 12.
‫Because the Python interpreter is going to follow a basic set of rules.
‫For example, if I do 20 minus three here.
‫And let's print this out.
‫Click Run.
‫I get eight because three times four gets evaluated first, which equals to 12, and then subtract it
‫from 20.
‫It's not that this goes first and then we multiply 17 by four.
‫And this operator precedence shouldn't be new, right?
‫If you've taken any sort of math class.
‫You understand that this is how well math works.
‫And this works the same in all programming languages.
‫So the order is this.
‫First we follow the brackets.
‫So whatever is wrapped in a bracket, we do first.
‫The second is we do the power of.
‫So whatever is done in the power of will be after parentheses.
‫For example, if I do parentheses here.
‫And then to the power of, let's say two or let's do plus two to the power of two.
‫Well, the first operation that will happen is 20 minus three, because that's the first precedence.
‫And then we do two to the power of two, because that's the next precedence.
‫And then only after we do that, we add these two together.
‫If I click Run.
‫I get 21, which again makes sense.
‫17 plus four.
‫After the power of we have the multiplication and division.
‫And then finally, the last precedence is addition and subtraction.
‫Now, this isn't going to be a math class.
‫Some people really love math.
‫Some people really don't.
‫But I want to just give you this basic understanding of operator precedence when you see it.
‫We'll do some exercises here to get accustomed to it.
‫But trust me, this is as mathy as we're going to get in this course.
‫The math part of the course is, well, just here.
‫It's going to get a lot more interesting as we learn about different data types.
‫I'll see you in the next one.
‫Bye bye.