Let's learn about some operators that is available in the python in this lecture.
So first of all is it always so we start to day edition so we have the addition operator so you can
add any numbers.
So this is to add to our brains so the unity plus that can be addition of single operations.
So the next one is a soft Texan so you can do this subtraction and the next one is a multiplication
operator which is going to multiply the two operations.
And next one is the divide left option by the right one so you can see something like six divisional
three.
It is going to give us the number in the.
So if you do something like seven divided by three you are going to get the decimal two.
So this is the division and the next one is a modulus which is going to give us the remainder of the
division.
So if I say seven to eight divide by nine and a 78 and it is modulus to get the remainder and you are
going to get the remainder it is six because nine it is with the remainder of six you can see over here.
So the next one is a flawed division.
This is important.
So and as I say five and divide this with let me say four.
You are getting only one and this flow division is the division that results into the whole number.
It just said to the left in the number line.
So if I say that let me divide with nine you'll get the gist over here.
So it is giving us the whole number.
That is the result.
If you see seven did that is modulus of nine was six.
So it is this it is in that remainder and giving us the whole number.
That is subsisted to the left in the number line.
That means this.
It is given over here in the floor division in we normally call this is a floor division.
And the next one is our exponent.
So when I say nine and in order to do exponent you have to this give this double is strict.
Okay.
This is w strict and to and it is giving us ninety one because nine of power of two is at one which
is nine multiplied by nine which is at 11 and this is the sum automatic operation that is given in a
python and we have now the comparison operator so companies operator is stars from the greater than
sign.
So if I say four is greater than five was because it is not true.
So this is the comparison.
So you get the value is a boolean when you do the comparison.
So next thing is if five is greater than four is that is true.
So next thing is you can see the smaller.
So four is smaller than nine which is true.
So this is another.
So let me just clear this.
So the next one is equal to so if I say five is equal equal nine which is false if six is equal equal
to six which is true.
This is the double equal which means that if this two is equal so if you do something like six equal
six this is not valid because you are thus assigning here so single equal means they are assigning you
are just trying to assign six to the six which is invalid.
So if you want to take six is equal to six that means it should be six equals six.
If I say something like a and b is six and six and if I take a is equal equal to B.
It is giving a string because you have a multiple assignment of six and six today and b anywhere taking
this condition which is obviously the true.
So next one is not true.
So if I say is not equal to B which is false because it is equal equal be the same saying that six is
not equal to okay six is not equal to seven which is true because six is not equal seven.
So next one is greater than equal or less than equal so do this be something like five is greatly called
the six which is false because five is smaller than six so both of these conditions was if I said something
like nine is greater equal to nine it is true because nine is equal to nine.
So either of these conditions would be true if this has to be true.
So this is your comparison operator and it is really easy and important the comparison operator.
So the next one is logical operator and we have and are and not as a logical operators.
So let's see how this logical operator work.
So first of all let me say something like a.
B let me say 7 and B should be it.
So I am just saying that a a is equal which is basically a equal or greater than 90 and b equally call
it.
So it is false here.
It is false if we see here we have given the two condition over here which is saying.
So first of all let's see this one.
It is saying B is equally coloured here the b value is 8 and it is equal equal 8 which is equal that
means you can see this condition over here when the two numbers are equal it is going to give us a true.
So this part is true but here you can see that a value is seven and seven is greater equal to 90 which
is obviously false.
So if any of this condition in the either side of end is false then it is going to give us a false.
So if it has to be true both of these conditions should be true in the case of and so if you see something
like a is equal equal to 7 and B's equally equal to it then it is true because each of these condition
is of this this statement is true that means it will give us true but if it is the case for the R as
in ninety or now not end and basically call it it is giving us true.
So you can see here if one of the condition is true that means this R will just make us happen that
is true it sooner need that each of these conditions would be to either of this condition is true it
is saying something like this sort of be true or this would be true if any or one of this is true then
it is going to give us the true condition that is for the R and in the case of a not you can simply
do that something like not of true is false are not of false is true so it this is basically the inverse
of what will use a spars with the not so this is the case when you see we have the logical operators
so we have to act here the automatic operators we have take the comparison operator we have also learned
about the logical operators and R and not operators they are really important operators.
So next thing is to learn about the import statement which is really easy to use so in order to do that
let me just create the new file and over here let me just close this first one Okay we have here.
So as this go to the Hill and Python docs which is the document section in the left hand side you have
the module sections so goes to the module 6 and lets go to the module 6 and in this place are over here
so we have this are the random module and solicit this random module so random is basically a module
that means it is the class containing all of these methods so everything you see here is inside these
random.
So if you want to make you use up this random order if you want to use this random inside your file
you have to first make use of this import statement so if you say import and random you are saying something
like random is inbuilt.
So this has been created by the byte a neutral computer scientist have created this set and a module
for us so is a computer programmer what we need to do is simply use them.
So in order to use them you have to make use of import the statement and the module that you want to
use.
So if you want to use another module so let's go back or if you want to just make use of.
Let me see.
Any any of this module so you can say OK I'm this going over here and if you want to make use of ABC
module then you see simply ABC and now you can use the methods are all the functions of this ABC module
but for now I'll just say random and now let's go back to the documentation and less going in for this
are and random and lists go downhill and see this surrender reigns matter so I'll do the same.
Print me random and if you want to use the method of this module you have to give the DART operator
because it has shown us here that functions for the integer.
And if you want to make use of that land grants it should be random first.
That is the module give the period and renderings will learn about this in the detail when we just starts
the classes and object in the python.
But for now just remember we have to make use of this random module that we just use here and dot in
the renderings we see the method inside this random module.
So we are not creating any rendering matter.
We are just using data renderings from the random fonts in a random module.
So now we have to give certain things inside these renderings so we have a start we have we stopped
and a step is optional.
So anything you see inside these square brackets is optional.
So we'll see started and stop so I'll just say it starts would be one stops would be six.
So let me just print this and let me say first and let me just say five minutes or two.
So what we are doing here is we are just creating every time we run this program.
It is generating the number from one to five.
Here it should be from 1 to 6 not 5 or should be from 1 to 6.
So every time you just run this new number so every time we run this new no new number and this new
normal again.
So every time you run it will be 1 2 6.
So random is generating us a random number from 1 to 6.
So this is the way to make you use up this random.
So if you just feel that random is too big to this right again over here you can just give these random
A's are with this allies in technique which is just silly naming your module with the name or using
its costume name.
Now you can make use of our let's see let's say this end run again and it is going to give us a new
name moreover here.
So this is the way to import any module so you can also import your mathematicians.
So what if I say import mat which is over here.
So let's go to the documentation and let's see for this random module our basic math module.
So it should be over here.
Math module and you can now make use of all of this function.
So what if I the same method still method this method over here.
Then we have to make use a print method and Matt the ceiling and this gives some decimal values and
let's save this place up 5.
Then you see the ceiling value over here printed is a 6.
So you can see right here which is getting us the value of 6.
If you see here the value is 6.
So you can see the floor if you want the 5 value to be printed it should be mad dirt floor.
If we save this impressive 5 5 will be printed which is the mathematical operation over here which is
saying here Matt floor and it will return the floor of the X. The largest integer less than or equal
to x which in this case is 5.
So this is the way to import your module and column method of that module using this period.
And if you want to the city name this math is yum.
You can do that.
Now if you just say math dot floor it is not going to work because math has not been defined.
You have just renamed this math is yum.
So it should be.
Now they say this again and press 5.
Then you'll see 5 again.
You can also do something like from math module import mi if you want only some fun then you can do
something like this from math module import me floor.
So if you do this now you do not need to this time period.
Because we have this included the floor method.
Now you can simply call for a method.
Let's say this again press your five you'll see five will be printed.
What if you do something like Yum dot or matte dot float again.
It is not going to work because math is not defined and you have this imported the floor from that math
module instead of this math.
So you sort directly call the floor over here.
So this is the way to import the other module from these inbuilt Python PBX library which is from this
python documents and you can make use of all of the functions that is given over there in your python
file.
So in the next lecture we'll see more conservative python.
See you in the next one.