WEBVTT

00:00.200 --> 00:04.790
So guys, we are going to continue the discussion with respect to our Python series and this video.

00:04.790 --> 00:07.010
We are going to deep dive into the operators.

00:07.040 --> 00:12.410
Uh, and we'll see that how with the help of Python we will be able to perform different different operations.

00:12.410 --> 00:14.570
Now here is the entire video outline.

00:14.570 --> 00:17.330
So first of all we will go ahead and see introduction to operators.

00:17.330 --> 00:23.300
Then we'll see multiple arithmetic operators like addition subtraction, multiple multiplication, division

00:23.300 --> 00:25.520
flow division modulus and exponential.

00:25.880 --> 00:31.190
Along with this we will see comparison operators like equal to not equal to, greater than, less than

00:31.400 --> 00:33.740
uh greater than or, equal to, less than or equal to.

00:33.770 --> 00:35.570
And we'll perform various operations.

00:35.600 --> 00:38.930
Along with this we'll also be seeing logical operators like and or not.

00:38.930 --> 00:43.340
And then we will be like all these things will be shown along with the practical examples.

00:43.370 --> 00:43.940
Right.

00:44.000 --> 00:45.410
So let me just go ahead.

00:45.410 --> 00:49.610
First of all, if you don't know about operators, guys, any kind of math, arithmetic operation or

00:49.610 --> 00:53.480
logical operation can be probably performed with this kind of operators.

00:53.510 --> 00:53.750
Okay.

00:53.780 --> 01:00.230
And uh, obviously when we write any Python code, we definitely require a lot of, uh, operations,

01:00.260 --> 01:02.070
probably to develop our projects and.

01:02.070 --> 01:05.760
All right, so quickly, let me just go ahead and create my code cell.

01:05.760 --> 01:08.700
And here, uh, I will show you one shortcut.

01:08.700 --> 01:12.000
You just press escape and press A automatically.

01:12.000 --> 01:13.350
Cells will get appended.

01:13.380 --> 01:14.010
Right.

01:14.010 --> 01:18.390
So first of all, uh, we are going to go ahead with arithmetic operations.

01:18.390 --> 01:19.020
Right.

01:19.020 --> 01:24.810
And uh, here with respect to the arithmetic operations, uh, let me just go ahead and create some

01:24.810 --> 01:26.550
variables like a is equal to ten.

01:26.910 --> 01:28.320
Uh, oops.

01:28.320 --> 01:32.070
So I will go ahead and write okay.

01:32.100 --> 01:33.060
This is getting added.

01:33.060 --> 01:34.500
We'll discuss about all these things.

01:34.500 --> 01:35.220
No worries.

01:35.220 --> 01:37.590
So A is equal to ten okay.

01:37.590 --> 01:41.250
And let's say I'm going to write B is equal to 15.

01:41.280 --> 01:45.300
If I want to perform any kind of operations over here.

01:45.330 --> 01:45.600
Right.

01:45.600 --> 01:48.390
Let's say I want to perform a basic arithmetic operation.

01:48.390 --> 01:49.290
I will go ahead and write.

01:49.320 --> 01:51.210
Result is equal to a plus B.

01:51.210 --> 01:54.180
So this is the addition operation that we specifically do.

01:54.180 --> 01:58.680
And here I can go ahead and print my result right a simple addition operation.

01:59.100 --> 02:01.680
So here my answer is 15 right.

02:01.710 --> 02:10.420
Similarly what I can actually do is that again, so this will basically be my ad ad result okay.

02:10.450 --> 02:15.220
Similarly, we can go ahead and create our subtraction result which will be nothing but a minus b.

02:16.420 --> 02:23.110
Then along with this we can go ahead and do our multiplication result right, which will be nothing

02:23.110 --> 02:24.640
but A multiplied by B.

02:25.300 --> 02:28.690
This is what we specifically get with respect to the multiplication operation.

02:29.380 --> 02:32.320
Along with multiple operation, we also have a division operation.

02:32.320 --> 02:33.580
So let me just go ahead and write.

02:33.580 --> 02:37.870
My division underscore result is equal to a divided by B.

02:38.020 --> 02:38.620
Okay.

02:39.160 --> 02:42.490
Uh and then we will also be having flow division.

02:42.490 --> 02:45.400
We'll discuss what is the difference between flow division also.

02:45.400 --> 02:49.750
So here you can see flow underscore div underscore results okay.

02:49.750 --> 02:55.180
And here you can see I have to just use a double slash like it's not divided.

02:55.180 --> 02:56.680
It's double divided by b okay.

02:56.710 --> 03:00.820
So we'll discuss about this why exactly we use this flow division okay.

03:00.820 --> 03:04.230
So this is my uh addition operation.

03:04.530 --> 03:07.860
This is my subtraction operation.

03:08.040 --> 03:10.320
A subtraction

03:12.090 --> 03:17.940
operation and the next one is my multiplication operation.

03:18.240 --> 03:21.630
And this is my division operation.

03:21.630 --> 03:23.250
And this is my flow division.

03:23.250 --> 03:25.140
We'll understand everything over here.

03:25.170 --> 03:26.010
Don't worry.

03:26.370 --> 03:26.880
Uh.

03:27.180 --> 03:28.110
Normal operation.

03:28.110 --> 03:29.130
I think you know it, right?

03:29.160 --> 03:30.330
It's basic maths.

03:30.360 --> 03:34.470
Then you also have, which is called as modulus operation.

03:34.500 --> 03:34.680
Okay.

03:34.710 --> 03:41.550
So here I'm going to basically go ahead and write modulus underscore result is equal to a modulus b.

03:41.700 --> 03:43.260
So we'll discuss about this.

03:43.260 --> 03:46.080
So this is exactly my modulus results.

03:46.320 --> 03:51.240
Or here I can write a modulus operation okay.

03:51.570 --> 03:57.000
And then finally you'll also be able to see that I will also use an exponential operation.

03:57.000 --> 04:03.660
And here I can go ahead and write exponential underscore result which will be nothing but a to the power

04:03.660 --> 04:08.150
to the power we basically say like we use this two star to the power of B.

04:08.180 --> 04:12.320
Okay, so this is basically my exponential operation.

04:12.710 --> 04:13.220
Okay.

04:14.030 --> 04:14.660
Perfect.

04:14.660 --> 04:16.910
Now let's go ahead and print this result.

04:16.910 --> 04:18.980
So here we have this.

04:19.010 --> 04:21.590
Then again I will go ahead and write print.

04:21.620 --> 04:24.620
Then again I will go ahead and write print.

04:24.650 --> 04:29.600
I'll copy this print multiple times because I need to display this results together.

04:29.960 --> 04:30.530
Okay.

04:30.530 --> 04:34.790
So now uh, let me just go ahead and write the subtract result.

04:35.060 --> 04:37.310
Uh, let me go ahead and.

04:37.340 --> 04:37.850
Oops.

04:37.850 --> 04:38.570
Just a second.

04:38.570 --> 04:39.680
Multiple results.

04:39.680 --> 04:41.990
So I will go ahead and paste it over here.

04:42.110 --> 04:43.250
And then we have our.

04:43.430 --> 04:44.330
Result.

04:44.450 --> 04:45.980
We'll paste it over here.

04:46.010 --> 04:48.230
Then we have our modulus result.

04:48.230 --> 04:49.490
We'll paste it over here.

04:49.520 --> 04:50.330
Then we have.

04:50.360 --> 04:51.560
Our exponential results.

04:51.560 --> 04:53.600
We'll paste it over here okay.

04:53.990 --> 04:56.990
One floor division result is pending.

04:56.990 --> 04:57.320
So let.

04:57.350 --> 04:59.090
Me just go ahead and write it over here.

04:59.090 --> 05:01.580
Print and I'll paste it over here.

05:01.580 --> 05:02.600
So here you can see.

05:02.630 --> 05:03.650
Addition is 15.

05:03.650 --> 05:04.910
Subtraction is five.

05:04.940 --> 05:06.530
Multiplication is 50.

05:06.560 --> 05:08.120
Division is 2.0.

05:08.150 --> 05:10.940
And float division result is nothing but two.

05:10.970 --> 05:11.300
Right?

05:11.330 --> 05:13.730
We will discuss about both of them by 2.0 and two.

05:13.760 --> 05:15.650
Then you have modulus operation.

05:15.650 --> 05:19.130
Modulus basically means that it will try to just give you the remainder.

05:19.160 --> 05:19.580
Right.

05:19.580 --> 05:24.020
So here you can see ten divided by five is uh like the remainder is zero.

05:24.020 --> 05:26.780
So that is the reason you will be able to see zero is over here.

05:26.780 --> 05:30.020
And when we do a to the power of B right.

05:30.050 --> 05:33.500
Ten to the power of five, we are actually going to get this value right.

05:33.530 --> 05:36.260
Now let's discuss more about this two okay.

05:36.290 --> 05:37.490
This two operation.

05:37.490 --> 05:42.740
Let's say that I want to uh, divide a number like ten divided by five.

05:42.740 --> 05:49.580
So I will be able to get two if I go ahead and write, let's say I will go ahead and write 21 divided

05:49.580 --> 05:50.060
by five.

05:50.060 --> 05:51.290
And obviously, you know the result.

05:51.290 --> 05:52.190
It is 4.2.

05:52.220 --> 05:52.730
Right.

05:52.730 --> 05:57.740
But if I use float division then what will happen is that I will get the answer as four.

05:57.740 --> 06:00.470
So whatever will be the float value, right.

06:00.470 --> 06:03.950
The lowest value, it will just remove the decimal and it will give you the output.

06:03.980 --> 06:04.490
Okay.

06:04.490 --> 06:06.320
So this is a basic example.

06:06.320 --> 06:09.480
Now you can perform various operations and we will see.

06:09.480 --> 06:11.520
I will try to create a calculator for you.

06:11.520 --> 06:16.290
And over here only I will show you that particular project also right as we go ahead.

06:16.350 --> 06:17.130
Perfect.

06:17.280 --> 06:23.340
Now the next step we are going to probably discuss about is comparison operators.

06:23.730 --> 06:24.030
Okay.

06:24.030 --> 06:29.970
So let me just go ahead and write it down and basically write it down as comparison operators.

06:29.970 --> 06:33.990
So guys now let's go ahead and see some of the comparison operators.

06:33.990 --> 06:39.060
Uh, now first of all uh we will go ahead with double equal to okay.

06:39.060 --> 06:41.640
So we will be using double equal to.

06:41.670 --> 06:45.270
Now let's say that I will go ahead and create a result.

06:45.270 --> 06:49.890
Or let me just go ahead and define a variable called as a is equal to ten okay.

06:49.920 --> 06:51.690
And b is equal to ten.

06:52.140 --> 06:55.590
Now if I want to probably compare this operators right.

06:55.620 --> 06:58.650
What I can actually do, I can go ahead and write my result.

06:58.650 --> 07:01.410
And let me just go ahead and simply use a tuple.

07:01.410 --> 07:08.230
I will talk about this brackets and just let me write it like a double equal to B or if I don't even

07:08.230 --> 07:11.770
want to write like this, just go ahead and write a double equal to be right.

07:11.770 --> 07:14.530
If I execute it, I will be able to get true over here.

07:14.530 --> 07:19.780
So this is nothing, but it is a more of a equal to comparison, where it will be comparing between

07:19.780 --> 07:22.450
two identifiers and what value it has.

07:22.450 --> 07:22.870
Right.

07:22.900 --> 07:27.280
The, the it basically compares the value that is present within this particular data type.

07:27.310 --> 07:27.880
Okay.

07:27.880 --> 07:30.340
Then this is equal to operator.

07:30.340 --> 07:31.030
So here I am.

07:31.030 --> 07:33.070
Let me go ahead and write equal to operator.

07:33.070 --> 07:34.330
And you can apply it.

07:34.330 --> 07:43.510
And on various different data types let's say I have str one, my string one I have like Krish okay.

07:43.510 --> 07:47.320
And str two I have Krish right.

07:47.350 --> 07:49.240
Same same string right.

07:49.240 --> 07:50.980
So capital, Krish and Krish.

07:51.010 --> 07:56.920
Now if I go ahead and write str one double equal to str two, then here you will be able to see I'm

07:56.920 --> 07:57.550
getting true.

07:57.580 --> 07:58.060
Right.

07:58.090 --> 08:01.420
Let's say if I use a small k okay.

08:01.450 --> 08:03.190
Then you can see that I'm getting a false.

08:03.190 --> 08:06.400
So this comparison is also with respect to case sensitive right.

08:06.400 --> 08:09.960
So whatever data is present with respect to this, it is just going to compare it.

08:09.990 --> 08:10.470
Okay.

08:10.470 --> 08:12.870
So this is some type of operations.

08:12.900 --> 08:17.880
The next comparison operation that we are going to discuss is nothing but not equal to.

08:18.210 --> 08:18.480
Okay.

08:18.510 --> 08:19.950
So not equal to.

08:19.980 --> 08:23.250
Which is denoted by this exclamation not equal to.

08:23.280 --> 08:28.080
Now if I go ahead and just write str one is not equal to str two.

08:28.110 --> 08:34.170
So obviously based on this comparison you can see that this is exactly false because both of the strings

08:34.170 --> 08:34.590
are true.

08:34.620 --> 08:34.980
Right.

08:34.980 --> 08:36.930
So that is the reason it is coming as false.

08:36.960 --> 08:42.990
Let's say if I go ahead and define again my string one and string two, let's say I go ahead and define

08:42.990 --> 08:47.160
it as string three or string three.

08:47.160 --> 08:49.680
And then this will basically be my string four.

08:49.680 --> 08:54.240
And now let me make this as a small character okay.

08:54.270 --> 08:59.610
And let me go ahead and write s three str three is not equal to str four.

08:59.640 --> 09:01.950
Now it should probably give me a true value.

09:01.980 --> 09:02.220
Why.

09:02.250 --> 09:04.920
Because both of them are not equal right.

09:04.920 --> 09:09.030
So this was another operation that is not equal to okay.

09:09.060 --> 09:12.970
Now coming to the next one, uh, which is basically called as greater than.

09:12.970 --> 09:15.520
So this will basically be greater than.

09:15.550 --> 09:20.860
So this is again a comparison operation, uh, which we can actually use, let's say, and this greater

09:20.860 --> 09:25.120
than operation, let's say I have a value like 45 A is equal to 45.

09:25.120 --> 09:27.370
Or let me just go ahead and run number one.

09:27.430 --> 09:28.420
Uh, 45.

09:28.450 --> 09:30.250
Number two is 55.

09:30.280 --> 09:34.690
Now, if I go ahead and write, number one is greater than, uh, number two.

09:34.720 --> 09:35.170
Right.

09:35.170 --> 09:38.650
So the answer may be false because number one is obviously small over here.

09:38.650 --> 09:41.890
So here you can probably see that I'm actually getting false.

09:41.920 --> 09:42.460
Right.

09:43.120 --> 09:46.090
So this is one example of greater than operation.

09:46.090 --> 09:50.620
And uh similarly if greater than is there then obviously less than should also be there.

09:50.620 --> 09:54.790
So less than operation which is denoted by.

09:54.820 --> 09:59.530
This greater than operation is basically denoted by this okay.

09:59.590 --> 10:02.020
Now in this case if I want to execute less than.

10:02.050 --> 10:06.040
So again if I go ahead and execute, num1 is less than num2.

10:06.700 --> 10:09.580
So here you'll be able to see that I'm able to get true right.

10:09.580 --> 10:11.060
You can also print this result.

10:11.060 --> 10:15.440
At the end of the day, I'm actually going to get a boolean value itself because this is a comparison

10:15.470 --> 10:16.100
operation.

10:16.100 --> 10:20.540
And with respect to all the comparison operation, we are either going to get true or false.

10:20.570 --> 10:22.880
Okay, now this is fine.

10:22.970 --> 10:24.830
Like less than is there greater than is there.

10:24.860 --> 10:28.100
Now obviously you also have something called as greater than or equal to right.

10:28.130 --> 10:34.160
So let me just go ahead and write greater than or equal to right.

10:34.190 --> 10:38.330
So here let me just go ahead and show you once more one more example.

10:38.330 --> 10:42.020
Let's say that, uh, um, I have a number one.

10:42.020 --> 10:47.480
Number one is equal to 45 and number two is equal to 45.

10:47.510 --> 10:48.020
Okay.

10:48.380 --> 10:58.040
Uh, now if I go ahead and put this condition, number one is greater than or equal to number two.

10:58.160 --> 11:01.700
So I'm basically going to get the answer right over here as true.

11:01.700 --> 11:04.310
Because obviously this is equal.

11:04.310 --> 11:06.680
At least one of the condition is basically getting true.

11:06.710 --> 11:07.070
Right.

11:07.070 --> 11:10.280
So if I go ahead and print it you'll be able to see this right.

11:10.650 --> 11:15.090
Now here you can actually see that yes, everything is working fine and I'm able to get through.

11:15.120 --> 11:20.190
Now similarly, there is one more comparison operation which is nothing but less than or equal to.

11:20.220 --> 11:24.060
Now, in this particular case, if I apply the condition less than or equal to two, again I'm going

11:24.090 --> 11:27.300
to get true because 45 is equal to 45.

11:27.330 --> 11:30.570
So one of the condition is getting matched less than or equal to.

11:30.600 --> 11:31.050
Right.

11:31.050 --> 11:36.480
If I go ahead and probably, uh, let's say in 40 number one, I go ahead and write 44.

11:36.510 --> 11:41.040
Then also it is going to be true because this condition is getting matched because number one is less

11:41.040 --> 11:41.940
than number two.

11:41.970 --> 11:42.300
Right.

11:42.330 --> 11:44.820
So over here, this is another one operation.

11:44.820 --> 11:45.330
Right.

11:45.330 --> 11:50.250
So just you got an idea about various comparison operation that we have actually done.

11:50.280 --> 11:51.840
Now let me do one more thing.

11:51.930 --> 11:57.450
Let me just go ahead and, uh, talk about logical operators.

11:57.480 --> 11:57.720
Okay.

11:57.750 --> 12:04.350
So here I'm going to basically create a field and let's say I'm going to write logical operators.

12:04.380 --> 12:04.830
Right.

12:04.860 --> 12:08.010
So one is that we have discussed about comparison operators.

12:08.010 --> 12:09.690
So let me make a cell over here.

12:09.690 --> 12:13.660
So that for your reference purpose also it becomes easy, right?

12:13.690 --> 12:18.250
So for cell comparison operators.

12:18.280 --> 12:18.820
Okay.

12:19.060 --> 12:19.780
Done.

12:19.810 --> 12:20.410
Perfect.

12:20.440 --> 12:21.700
So comparison operators.

12:21.700 --> 12:23.530
And here you have all the things right.

12:23.530 --> 12:25.930
And now we are going to discuss about logical operators.

12:25.960 --> 12:34.060
Now logical operators basically means there are 311 is and one is uh not okay.

12:34.510 --> 12:36.070
And one is or.

12:36.910 --> 12:37.270
Right.

12:37.270 --> 12:40.900
So most common operation in logical operator is something like this.

12:40.900 --> 12:43.150
Now let me talk about this right.

12:43.180 --> 12:49.810
In the case of and you know and if you know about digital logic gates, I hope in college at least some

12:49.810 --> 12:56.500
idea you have about it in case of and when both A and B right are true, then only you will be able

12:56.500 --> 12:59.710
to get the output as true, otherwise it will be completely false.

12:59.710 --> 13:00.820
What do I mean by that?

13:00.820 --> 13:02.560
Let's say I have two boolean variable.

13:02.560 --> 13:03.730
One is x.

13:03.760 --> 13:06.280
Let's say it is true right now.

13:06.280 --> 13:13.580
In this particular case, if my y is also true right now, if I go ahead and write okay, Let's say

13:13.580 --> 13:21.020
that I go ahead and create my result and let me go ahead and write it as X and C and operation.

13:21.020 --> 13:30.860
We have to use Y right now if I go ahead and print my result, if I go ahead and print my result, you'll

13:30.890 --> 13:32.540
be able to see that I'm able to get true.

13:32.570 --> 13:33.140
Right.

13:33.140 --> 13:34.730
Because both of them are true.

13:34.760 --> 13:35.270
Right.

13:35.270 --> 13:41.720
But in this particular case, if I just copy this and paste it over here and this case now let me say

13:41.720 --> 13:46.970
that if y is false, then if I go ahead and execute, it is going to come false, right?

13:47.000 --> 13:53.330
Even though this may be true and this may be false, then also I'm able to get false.

13:53.330 --> 13:56.180
So in the case of an operation, right.

13:56.210 --> 14:01.970
Always you need to make sure that whenever both the variable will be boolean true, then only your output

14:01.970 --> 14:04.190
will be true, right in the case of an operation.

14:04.220 --> 14:07.460
Now let's go ahead and understand about our operation.

14:07.460 --> 14:17.740
Now, in the case of our operation, uh, only in the case of only in the case when x and y are false,

14:18.550 --> 14:27.670
x and y are false, then only we are going to get the output as false or the remaining all the time.

14:28.450 --> 14:31.870
If I keep it as true or false or true true or.

14:31.900 --> 14:32.680
Okay, sorry.

14:32.680 --> 14:39.520
This is and right okay or now any time you will be able to see whenever I keep x, either one of them

14:39.520 --> 14:41.110
is true or both of them is true.

14:41.110 --> 14:43.030
I am always going to get the output as true.

14:43.240 --> 14:47.020
Otherwise, if both of them are false, I am always going to get the output as false.

14:47.020 --> 14:51.310
So this is the most important thing with respect to the Or operation, right?

14:51.340 --> 14:57.640
And finally you'll be able to see that I also have another operation which is called as not and not

14:57.670 --> 15:01.060
operation is nothing, but it is the reverse.

15:01.090 --> 15:03.520
It is a just a reverse of a boolean variable.

15:03.550 --> 15:03.910
Right?

15:03.940 --> 15:05.440
What do I mean by that?

15:05.470 --> 15:08.080
Let's say I have x is equal to true.

15:08.170 --> 15:08.860
Right.

15:08.860 --> 15:12.700
And if I go ahead and write not of x, then what I am able to get.

15:12.730 --> 15:14.830
See inverse of this x right.

15:14.860 --> 15:16.670
So here I'm able to get false.

15:16.790 --> 15:17.270
Right.

15:17.270 --> 15:21.530
So naught is nothing, but it is an inverse of any boolean variable.

15:21.560 --> 15:27.380
So if this boolean variable is false then if I go ahead and write not of x then I am actually able to

15:27.380 --> 15:29.390
see that I'll be getting true right.

15:29.480 --> 15:33.890
So here we have discussed various comparison logical operators.

15:33.920 --> 15:37.820
Again it will be important for various arithmetic operations as such.

15:37.850 --> 15:45.080
One A good code example arithmetic or a simple calculator will be designing and you can probably check

15:45.110 --> 15:45.950
out this code.

15:45.980 --> 15:51.080
Okay so here you can see I'm giving float enter first number second number.

15:51.080 --> 15:56.000
And you are performing addition subtraction multiplication division modulus exponentiation.

15:56.000 --> 15:57.230
And here you are displaying it.

15:57.230 --> 15:58.820
So let's go ahead and execute this.

15:58.850 --> 16:04.310
So if I go ahead and write uh 12 and execute it for execute it.

16:04.310 --> 16:06.290
So here is what is my output.

16:06.320 --> 16:06.860
Right.

16:07.190 --> 16:10.760
So I hope you were able to understand regarding operators.

16:10.760 --> 16:12.680
So this was it from my side.

16:12.710 --> 16:16.040
Uh yeah I will see you all in the next video.

16:16.040 --> 16:16.520
Thank you.

16:16.550 --> 16:16.970
Take care.
