Hello developers and welcome back.
We finished from basic data types.
Now let's move to the operators in Python.
Before we begin again guys we have those files.
You should upload them to the Google Colab.
You can download them from the resources folder.
And we're going to upload many files later and many notebooks.
So all those notebooks are available to download from the resources folder under each section.
Operators allow you to perform operations on variables and values.
Python divides the operators in many groups.
We have arithmetic assignment comparison.
Logical identity.
Membership, bitwise operators.
Let's start with the most commonly used arithmetic operators.
The addition subtraction addition includes the plus sign.
Subtraction minus sign multiplication.
The asterisk Division forward slash floor division two double forward slash modulus which is the remainder
the percentage and exponentiation which is two asterisks.
Now let's try some calculations.
We have two variables a and b.
A equals ten b equals to three.
We have a lot.
We have all those arithmetic operators.
The first one which is the string.
This will be printed because it's a string.
And here we have the operation a plus b a minus b a times b a over b and so on.
Let's run the cell and we have this output ten plus three equals to 1310 minus three 710 times three
3010 over 33.333.
Those are ordinary and arithmetic operations.
We're going to introduce some of of Operators and operations that are not familiar with in school.
We have the floor division.
Floor division returns the integer part of the division result, discarding any remainder.
So for example here we have ten over three.
It's 3.333.
The integer part is three and the decimal part is this.
We discard this and we eliminate this part.
And we keep the integer part which is three modulus.
I want from you to focus with me.
The percentage symbol is the modulo operator which gives you the remainder after division.
What's happening here?
We have ten over three equals to 3.333.
Integer division is three.
And how many whole times three fits to into ten which is one.
So we have three times 0.333 equals to one, which is the module in another way how to calculate the
remainder.
So ten over three we have 3.333.
This is the arithmetic operator division.
Now in in ten.
How many whole times three.
We have three times three equals to nine.
How many uh how many numbers are uh what I need to get ten from nine.
I need plus one.
So the remainder is one.
We need to get whole numbers.
So in ten we have three times three plus one which is ten.
Again guys the modulus is the remainder.
I'll show you another example.
Print eight modulo two eight modulo two equals to four.
There is no remainder but 8 or 9 Modulo two, we have one because eight eight divided by two equals
two for any remainder.
No, because this is a whole number.
This is an integer.
There's no decimal and the division is complete.
But if nine over two we get 4.5 we can get the modulo in another way using the decimal part multiplied
by the divisor.
So 0.5 times two equals to one which is the remainder.
This remainder plus four times two equals to nine.
This is how we calculate the module.
Another example to understand well brand 15 modulo four run we get three because again the calculator
15 over four equals to 3.75.
If we get the decimal decimal number 0.75 multiplied by the decimal part, we get multiplied by the
divisor.
We get three.
Three plus four times three we get 50.
Okay.
So we multiply the decimal part by the divisor in order to get the remainder.
Or you can simply get the floor division.
When we uh we subtract from the division.
The floor division we get the decimal part.
This decimal part is multiplied by the divisor and we'll get the modulus okay.
Those are very important.
Uh, arithmetic operators operations.
You should know also we have the power a power b a to power B equals to 1000.
So ten to power three equals to 1000.
This is the two asterisks.
Double asterisk mean the exponentiation okay.
Those are the arithmetic operators in Python.