So guys, we are going to continue the discussion with respect to our Python series and this video.
We are going to deep dive into the operators.
Uh, and we'll see that how with the help of Python we will be able to perform different different operations.
Now here is the entire video outline.
So first of all we will go ahead and see introduction to operators.
Then we'll see multiple arithmetic operators like addition subtraction, multiple multiplication, division
flow division modulus and exponential.
Along with this we will see comparison operators like equal to not equal to, greater than, less than,
uh greater than or, equal to, less than or equal to and will perform various operations.
Along with.
This will also be seeing logical operators like and or not.
And then will will be like all these things will be shown along with the practical examples.
Right.
So let me just go ahead.
First of all, if you don't know about operators, guys, any kind of math, arithmetic operation or
logical operation can be probably performed with this kind of operators.
Okay.
And, uh, obviously when we write any Python code, we definitely require a lot of, uh, operations,
uh, probably to develop our projects and.
All right, so quickly, let me just go ahead and create my code cell.
And here, uh, I will show you one shortcut.
You just press escape and press A automatically.
Cells will get appended.
Right.
So first of all, uh, we are going to go ahead with arithmetic operations.
Right.
And, uh, here with respect to the arithmetic operations, uh, let me just go ahead and create some
variables like a is equal to ten.
Uh, oops.
So I will go ahead and write okay.
This is getting added.
We'll discuss about all these things.
No worries.
So a is equal to ten okay.
And let's say I'm going to write B is equal to 15 if I want to perform any kind of operations over here.
Right.
Let's say I want to perform a basic arithmetic operation.
I will go ahead and write.
Result is equal to A plus B.
So this is the addition operation that we specifically do.
And here I can go ahead and print my result right a simple addition operation.
So here my answer is 15 right.
Similarly what I can actually do is that again so this will basically be my ad ad result.
Okay.
Similarly we can go ahead and create our subtraction result which will be nothing but a minus B.
Then uh, along with this we can go ahead and do our multiplication result, right, which will be nothing
but A multiplied by B.
Uh, this is what we specifically get with respect to the multiplication operation.
Uh, along with multiple operation, we also have a division operation.
So let me just go ahead and write.
My division underscore result is equal to a divided by B.
Okay.
Uh and then we will also be having flow division.
We'll discuss what is the difference between flow division also.
So here you can see flow underscore div underscore results okay.
And here you can see I have to just use a double slash like it's not divided, it's double divided by
B.
Okay.
So we'll discuss about this.
Why exactly we use this flow division okay.
So this is my, uh, addition operation.
This is my subtraction operation.
So subtraction
operation.
And the next one is my multiplication operation.
And this is by division operation.
And this is my flow division.
We'll understand everything over here.
Don't worry.
Uh.
Normal operation.
I think you know it, right?
It's basic maths.
Then.
Uh, you also have, which is called as modulus operation.
Okay, so here I'm going to basically go ahead and write modulus underscore result is equal to a modulus
b.
So we'll discuss about this.
So this is exactly my modulus results.
Or here I can write a modulus operation okay.
And then finally you'll also be able to see that I will also use an exponential operation.
And here I can go ahead and write exponential underscore result which will be nothing but a to the power
to the power.
We basically say like we use this two star to the power of B.
Okay, so this is basically my exponential operation.
Okay.
Perfect.
Now let's go ahead and print this results.
So here we have this.
Then again I will go ahead and write print.
I'll copy this print multiple times because I need to display this results together okay.
So now uh, let me just go ahead and write the subtract result.
Uh, let me go ahead and oops.
Just a second.
Multiple results.
So I will go ahead and paste it over here.
And then we have our div result.
We'll paste it over here.
Then we have our modulus result.
We'll paste it over here.
Then we have our exponential results.
We'll paste it over here okay.
One flow division result is pending, so let me just go ahead and write it over here.
Print and I'll paste it over here.
So here you can see addition is 15.
Subtraction is five.
Multiplication is 50.
Division is 2.0.
And floor division result is nothing but two.
Right.
We will discuss about both of them by 2.0 and two.
Then you have modulus operation.
Modulus basically means that it will try to just give you the remainder right.
So here you can see ten divided by five is uh like the remainder is zero.
So that is the reason you will be able to see zero is over here.
And when we do a to the power of B right, ten to the power of five, we are actually going to get this
value right.
Now.
Let's discuss more about this two okay.
This two operation.
Let's say that I want to uh, divide a number like ten divided by five.
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
by five.
And obviously you know the result.
It is 4.2, right.
But if I use floor division then what will happen is that I will get the answer as four.
So whatever will be the floor value right.
The lowest value, it will just remove the decimal and it will give you the output.
Okay.
So this is a basic example.
Now you can perform various operations.
Uh, and uh we will see I'll try to create a calculator for you.
And over here only I will show you that particular project also right as we go ahead.
Perfect.
Uh, now uh, the next step we are going to probably discuss about is comparison operators.
Okay.
So let me just go ahead and write it down and basically write it down as comparison operators.
So guys now let's go ahead and see some of the comparison operators.
Uh, now first of all uh we will go ahead with double equal to okay.
So we will be using double equal to.
Now let's say that uh, I will go ahead and create a result or let me just go ahead and define a variable
called as a is equal to ten okay.
And b is equal to ten.
Now if I want to probably compare this operators right.
What I can actually do I can go ahead and write my result and let me just go ahead and simply use a
tuple.
I will talk about this brackets and just let me write it like a double equal to B.
Or if I don't even want to write like this, just go ahead and write a double equal to B, right?
If I execute it, I will be able to get true over here.
So this is nothing, but it is a more of a equal to comparison, where it will be comparing between
two identifiers and what value it has.
Right.
The the.
It basically compares the value that is present within this particular data type.
Okay.
Then this is equal to operator.
So here I'm let me go ahead and write equal to operator.
And you can apply it.
And on various different data types let's say I have str one, my string one I have like Krish okay.
And str two I have crush, right?
Same same string.
Right.
So capital crush and crush.
Now if I go ahead and write str one double equal to STR2, then here you'll be able to see I'm getting
true.
Right.
Let's say if I use a small k okay.
Then you can see that I'm getting a false.
So this comparison is also with respect to case sensitive right.
So whatever data is present with respect to this it is just going to compare it okay.
Okay.
So this is uh, some type of operations.
Uh, the next comparison operation that we are going to discuss is nothing but not equal to.
Okay.
So not equal to which is denoted by this exclamation not equal to.
Now if I go ahead and just write str one is not equal to str two.
So obviously based on this comparison you can say that this is exactly false because both of the strings
are true.
right?
So that is the reason it is coming as false.
Let's say if I go ahead and define again my string one and string two, let's say I go ahead and define
it as string three.
Uh string three.
And then this will basically be my string four.
And now let me make this as a small character okay.
And let me go ahead and write s three str three is not equal to str four.
Now it should probably give me a true value.
Why?
Because both of them are not equal right.
So this was another operation that is not equal to okay.
Now coming to the next one uh, which is basically called as greater than.
So this will basically be greater than.
So this is again a comparison operation, uh, which we can actually use, let's say, and this greater
than operation, let's say I have a value like 45 is equal to 45.
Or let me just go ahead and one number one, uh, 45, number two is 55.
Now if I go ahead and write, number one is greater than, uh, number two.
Right.
So the answer may be false because number one is obviously small over here.
So here you can probably see that I'm actually getting false.
Right.
So this is uh one example of greater than operation.
And uh similarly if greater than is there then obviously less than should also be there.
So less than operation which is denoted by.
This greater than operation is basically denoted by this okay.
Now in this case if I want to execute less than.
So again if I go ahead and execute num one is less than num two.
So here you'll be able to see that I'm able to get true right.
You can also print this result.
At the end of the day, I'm actually going to get a boolean value itself because this is a comparison
operation.
And with respect to all the comparison operation we are either going to get true or false.
Okay.
Now this is fine line less than.
Is there greater than is there.
Now obviously you also have something called as greater than or equal to right.
So let me just go ahead and write greater than or equal to right.
So here uh, let me just go ahead and show you once more, one more example.
Let's say that, um, um, I have a number one.
Number one is equal to 45 and number two is equal to 45.
Okay.
Uh, now if I go ahead and put this condition number one is greater than or equal to number two.
So I'm basically going to get the answer right over here as true.
Because obviously this is equal.
At least one of the condition is basically getting true.
Right.
So if I go ahead and print it you'll be able to see this right now here you can actually see that yes,
everything is working fine and I'm able to get true.
Now.
Similarly there is one more comparison operation which is nothing but less than or equal to.
Now, in this particular case, if I apply the condition less than or equal to two, again, I'm going
to get true because 45 is equal to 45.
So one of the condition is getting matched less than or equal to right.
If I go ahead and probably, uh, let's say in 40 number one, I go ahead and write 44.
Then also it is going to be true because, uh, this condition is getting matched because number one
is less than number two.
Right.
So over here, this is another one operation.
Right.
So just you got an idea about various comparison operation, uh, that we have actually done.
Now, let me do one more thing.
Uh, let me just go ahead and, uh, talk about logical operators.
Okay.
So here I'm going to basically create a field and let's say I'm going to write logical operators.
Right.
So one is that we have discussed about comparison operators.
So let me make a cell over here so that for your reference purpose also it becomes easy right.
So for cell comparison operators.
Okay.
Done.
Perfect.
So comparison operators.
And here you have all the things right.
And now we are going to discuss about logical operators.
Now logical operators basically means the 311 is and one is uh not okay.
And one is or.
Right.
So most common operation in logical operator is something like this.
Now let me talk about this right.
In the case of and you know and if you know about digital logic gates, I hope in college at least some
idea you have about it in case of and when both A and B right are true, then only you will be able
to get the output as true, otherwise it will be completely false.
What do I mean by that?
Let's say I have two boolean variable.
One is x.
Let's say it is true right now.
In this particular case, if my y is also true right now, if I go ahead and write okay, let's say
that I go ahead and create my result and let me go ahead and write it as X and C and operation.
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
be able to see that I'm able to get true right?
Because both of them are true.
Right?
But in this particular case, if I just copy this and paste it over here and this case now, let me
say that if y is false, then if I go ahead and execute it, it's going to come false, right?
Even though this may be true and this may be false, then also I am able to get false.
So in the case of and operation right always you need to make sure that whenever both the variable will
be boolean true, then only your output will be true, right in the case of an operation.
Now let's go ahead and understand about our operation.
Now, in the case of our operation, uh, only in the case of only in the case when x and y are false,
x and y are false, then only we are going to get the output as false.
Uh, the remaining all the time.
If I keep it as true or false or true?
True.
Uh, okay.
Uh, sorry.
This is.
And.
Right.
Okay.
Or now, any time you'll be able to see whenever I keep x, X, either one of them is true or both of
them is true, I'm always going to get the output as true.
Otherwise, if both of them are false, I'm always going to get the output as false.
So this is the most important thing with respect to the Or operation, right?
And finally you'll be able to see that I also have another operation which is called as not and not
operation is nothing, but it is the reverse.
It is just a reverse of a boolean variable, right?
What do I mean by that?
Let's say I have x is equal to true.
Right?
And if I go ahead and write not of x then what?
I'm able to get c inverse of this x right.
So here I'm able to get false right.
So not is nothing.
But it is an inverse of any boolean variable.
So if this boolean variable is false then if I go ahead and write not of x then I'm actually able to
see that I'll be getting true.
Right.
So here we have discussed various comparison logical operators.
Again it will be important for various arithmetic operations as such.
One uh good code example arithmetic or uh simple calculator will be designing and you can probably check
out this code okay.
So here you can see I'm giving float enter first number second number.
And you are performing addition subtraction, multiplication, flow division, modulus exponentiation.
And here you are displaying it.
So let's go ahead and execute this.
So if I go ahead and write uh 12 and execute it for execute it.
So here is what is my output.
Right.
So I hope uh you were able to understand regarding operators.
Uh, this was it from my side.
Uh, yeah.
Uh, I will see you all in the next video.
Thank you.
Take care.