Welcome back.
We're almost done with the math section in this video.
We're going to discuss some of the common important operators that we have in Python.
So here's a simple table on the left side is the symbol that you will use in Python things you're probably
familiar with at least.
Plus and minus and most likely the star and the slash for division and then over here is the name of
the operator.
Now these last three I know kind of weird looking.
If you haven't come across them before.
We will get to them in the next video.
But for now she's going to talk about addition subtraction multiplication and most importantly division.
OK.
So let's go over to my terminal and I'll open up Python 3.
We already saw we can do things like 1 plus 3 or 40 minus 4.5 and we get a float because we used to
float as part of the expression.
But what I wanted to call your attention to is what happens when we divide.
So we could do something like 1 divided by two.
What do you think the answer will be.
These are two integers 1 and 2.
So neither one of them is a float.
What type of data float or integer will the result be.
All right and like get that it's a float.
So in some programming languages this actually would not give you a float and it would round down to
zero and just cut off a decimal.
But in Python division always returns a float you always get a float back.
Now there's a way around it.
If you don't want that for some reason I'll show you in the next video.
But if we do something like 1 divided by three we get 0.3 333 repeating.
So that's division that's probably the most quirky most important thing to point out in this video.
But I also want to talk about the order of operations.
So if you don't remember the order of operations or math I won't go into the whole thing but there is
a hierarchy to how these operations do these operators are evaluated.
So if we just add something like 1 for us two times five divided by three what happens first there's
this thing called PEM DOS.
It helps some people remember parentheses exponent multiplication division addition subtraction.
So first would be this multiplication.
And then this division.
So we would get 10 divided by three plus one.
So that's three point three three three plus one.
So we get four point three but we could also do with just a couple of parentheses completely alter how
this works.
So now we do the one plus two first.
So we get three times five.
It's going to be 15 divided by three.
And the answer this time is 5.0.
All right.
So I won't for you I promise I'd keep this short but I just wanted to highlight that parentheses work
the same way that they do and just paper and pen math so we can add parentheses wherever we want to
manipulate the order that things are calculated in anyway.
OK.