WEBVTT

00:00.080 --> 00:02.200
Hello developers and welcome back.

00:02.240 --> 00:04.600
We finished from basic data types.

00:04.600 --> 00:07.760
Now let's move to the operators in Python.

00:07.920 --> 00:13.160
Before we begin again guys we have those files.

00:13.160 --> 00:16.200
You should upload them to the Google Colab.

00:16.200 --> 00:18.880
You can download them from the resources folder.

00:19.080 --> 00:24.000
And we're going to upload many files later and many notebooks.

00:24.000 --> 00:31.400
So all those notebooks are available to download from the resources folder under each section.

00:31.440 --> 00:37.120
Operators allow you to perform operations on variables and values.

00:37.120 --> 00:40.360
Python divides the operators in many groups.

00:40.600 --> 00:44.720
We have arithmetic assignment comparison.

00:44.840 --> 00:46.920
Logical identity.

00:46.960 --> 00:50.280
Membership, bitwise operators.

00:50.320 --> 00:54.240
Let's start with the most commonly used arithmetic operators.

00:54.560 --> 01:00.960
The addition subtraction addition includes the plus sign.

01:01.000 --> 01:04.120
Subtraction minus sign multiplication.

01:04.160 --> 01:14.120
The asterisk Division forward slash floor division two double forward slash modulus which is the remainder

01:14.320 --> 01:18.360
the percentage and exponentiation which is two asterisks.

01:18.560 --> 01:20.520
Now let's try some calculations.

01:20.520 --> 01:23.560
We have two variables a and b.

01:23.840 --> 01:26.920
A equals ten b equals to three.

01:26.960 --> 01:28.320
We have a lot.

01:28.440 --> 01:31.160
We have all those arithmetic operators.

01:31.400 --> 01:33.400
The first one which is the string.

01:33.560 --> 01:36.280
This will be printed because it's a string.

01:36.520 --> 01:44.560
And here we have the operation a plus b a minus b a times b a over b and so on.

01:44.800 --> 01:56.520
Let's run the cell and we have this output ten plus three equals to 1310 minus three 710 times three

01:56.720 --> 02:01.480
3010 over 33.333.

02:01.800 --> 02:05.680
Those are ordinary and arithmetic operations.

02:05.680 --> 02:16.160
We're going to introduce some of of Operators and operations that are not familiar with in school.

02:16.160 --> 02:18.040
We have the floor division.

02:18.080 --> 02:25.680
Floor division returns the integer part of the division result, discarding any remainder.

02:25.880 --> 02:29.840
So for example here we have ten over three.

02:30.160 --> 02:32.040
It's 3.333.

02:32.360 --> 02:37.080
The integer part is three and the decimal part is this.

02:37.120 --> 02:41.560
We discard this and we eliminate this part.

02:41.560 --> 02:46.800
And we keep the integer part which is three modulus.

02:46.840 --> 02:49.280
I want from you to focus with me.

02:49.280 --> 02:58.120
The percentage symbol is the modulo operator which gives you the remainder after division.

02:58.160 --> 02:59.520
What's happening here?

02:59.600 --> 03:04.280
We have ten over three equals to 3.333.

03:04.320 --> 03:07.320
Integer division is three.

03:07.560 --> 03:14.520
And how many whole times three fits to into ten which is one.

03:14.520 --> 03:25.270
So we have three times 0.333 equals to one, which is the module in another way how to calculate the

03:25.270 --> 03:25.910
remainder.

03:25.910 --> 03:29.390
So ten over three we have 3.333.

03:29.430 --> 03:31.950
This is the arithmetic operator division.

03:31.950 --> 03:34.710
Now in in ten.

03:34.870 --> 03:37.670
How many whole times three.

03:37.950 --> 03:41.430
We have three times three equals to nine.

03:41.630 --> 03:49.230
How many uh how many numbers are uh what I need to get ten from nine.

03:49.230 --> 03:51.470
I need plus one.

03:51.470 --> 03:53.950
So the remainder is one.

03:53.990 --> 03:56.590
We need to get whole numbers.

03:56.590 --> 04:04.030
So in ten we have three times three plus one which is ten.

04:04.070 --> 04:07.790
Again guys the modulus is the remainder.

04:07.830 --> 04:10.390
I'll show you another example.

04:10.430 --> 04:16.070
Print eight modulo two eight modulo two equals to four.

04:16.110 --> 04:27.550
There is no remainder but 8 or 9 Modulo two, we have one because eight eight divided by two equals

04:27.550 --> 04:29.430
two for any remainder.

04:29.470 --> 04:31.910
No, because this is a whole number.

04:31.910 --> 04:33.190
This is an integer.

04:33.390 --> 04:36.510
There's no decimal and the division is complete.

04:36.510 --> 04:47.070
But if nine over two we get 4.5 we can get the modulo in another way using the decimal part multiplied

04:47.070 --> 04:49.190
by the divisor.

04:49.390 --> 04:54.710
So 0.5 times two equals to one which is the remainder.

04:54.750 --> 05:00.070
This remainder plus four times two equals to nine.

05:00.310 --> 05:03.230
This is how we calculate the module.

05:03.270 --> 05:15.070
Another example to understand well brand 15 modulo four run we get three because again the calculator

05:15.230 --> 05:20.190
15 over four equals to 3.75.

05:20.230 --> 05:29.790
If we get the decimal decimal number 0.75 multiplied by the decimal part, we get multiplied by the

05:29.790 --> 05:30.470
divisor.

05:30.710 --> 05:32.110
We get three.

05:32.150 --> 05:37.710
Three plus four times three we get 50.

05:37.750 --> 05:38.270
Okay.

05:38.430 --> 05:44.110
So we multiply the decimal part by the divisor in order to get the remainder.

05:44.150 --> 05:46.950
Or you can simply get the floor division.

05:47.110 --> 05:51.470
When we uh we subtract from the division.

05:51.510 --> 05:54.430
The floor division we get the decimal part.

05:54.470 --> 06:00.590
This decimal part is multiplied by the divisor and we'll get the modulus okay.

06:00.910 --> 06:02.750
Those are very important.

06:02.870 --> 06:06.550
Uh, arithmetic operators operations.

06:06.550 --> 06:15.310
You should know also we have the power a power b a to power B equals to 1000.

06:15.430 --> 06:20.270
So ten to power three equals to 1000.

06:20.310 --> 06:22.750
This is the two asterisks.

06:22.790 --> 06:27.230
Double asterisk mean the exponentiation okay.

06:27.350 --> 06:31.430
Those are the arithmetic operators in Python.
