0:00
Hello, welcome to chapter 2 that is Python identifiers and operators
0:04
In this chapter I will be explaining the names and operations that we're performing Python programs
0:14
Okay, so what is identifier? A name in Python program is called as identifier
0:20
Name can be in a class, function name, module name or a variable
0:24
So just let me give you an example here. I'm just defining a variable called a
0:29
called a with value 10 also I can give the name of glass anything or xyz
0:35
glass name and certain functions inside that whenever I'm calling that glass
0:41
that is nothing but an identifier of this particular glass otherwise I can
0:47
also define the function name also I can define an object name so everything
0:52
that you are defining enough Python is an option and whenever you are
0:57
defining that object a name it is an identifier right so there are certain rules associated
1:03
with that so it should be start with uppercase or lower case if at all it is starting with
1:09
underscore it will be a private one we will talk about that in coming flights
1:14
identified should not start with digits that means 1a or 1 x y z these kind of names are
1:21
not allowed these are case sensitive we see an example of it we cannot use reserved
1:27
words as identifiers, right? So there are 32 around odd reserved words in Python
1:33
which we cannot use as identifiers. And as there is no limit, but it is assumed
1:38
or it is suggested that you should not cross 72 word limit
1:43
whenever you are defining identifiers. And in Python, we do not use dollar symbol. Okay
1:49
So these are the rules associated with identifiers. So in a summary, we can say
1:57
So Alphabet, symbols, upper lowercase, digits and underscore are allowed. But 1 to 3 total is not allowed
2:07
Total 1 to 3 is allowed because it is starting with numbers
2:10
Whenever it is starting with numbers, it is not allowed. Identify as a key sensitive
2:15
The example is for example I am defining a variable with T small and I am defining a variable
2:22
with T capital. This both will have different values whenever you are printing then it will be used
2:27
you a respect to output. That means these are case sensitive ones. Okay so whenever
2:33
identifier is starting with underscore it is private. Whenever double underscore it will be
2:38
strongly private or you can also say single underscore is protected and this is private
2:45
one. And identify start with 2 underscore at start and 2 underscore add back and nothing but
2:52
magic methods. So there are several matching methods that we use in Python kind of one-wing
2:56
will be an it method which is used as constructors in your classes
3:01
Also there are different STR methods in these this is add method
3:07
There are different methods which we use as magic mentors Right So this is one of the examples where we are using identifiers together to define a code So this code is to bring the area of triangle
3:22
For example, one identifier is called as base with value 10. Another one is height with 20
3:29
So these are two variables. Then third variable I define is area
3:32
Wherein I am defining as 1 by 2 multiplied by base multiplied by height
3:37
So base means it will take the value of 10. it means it will take the value of 20 so it will be 1 by 2 into 10 into 20 so that means it will be
3:48
unread so whenever you are printing this is our built print function of Python so you can see
3:55
area of the mentioned triangle is this is the string that you have returned you can change it
3:59
as for your mid common and mean value of or variable so the value is unread so the value is
4:06
and read so and read will be returned to your output so this is the way you are using identifiers
4:13
inside your code we don't want to have n number of sales wherein you can define the CSS code or
4:18
markdown so this is markdown which i have defined wherein you can just write a text and inside a
4:24
code block you can write your codes so if at all you wanted to launch your jupiter notebook
4:30
you have to just go to your repository where you have written the code or you want to
4:36
to write a code, open the command prompt, and inside a command prompt just write Jupiter Nonbook
4:43
So it will open that particular location inside your browser and there you can open your file
4:51
So for example it has opened that particular folder with you and we are talking about
4:55
identifiers and operators IPYND is an extension to Jupiter notebook file. So inside that file you can do your coding stuff like how we were discussing
5:05
these are the markdowns these are the calls you have to run this you have to just do
5:10
shift and enter so this e value will be printed in print function now another variable
5:16
name Python a 1 to 3 with value Python you are printing it will be giving you output but now
5:23
as we have discussed the rules if you are starting this variable name with digit first it
5:30
should through an error right so i am just commenting out one of
5:35
the line to comment it out you have to just write hash in front of your put so that line
5:40
will be commented out and it won't be considered by any question now whenever i am executing
5:46
it will be giving output as invalid syntax because 1-2-3-e is not a valid identifier name now this is already
5:56
an example which we saw just to run it out do shift enter it will give you an output another
6:02
example is hello word this string stored in this value where an identifier I'm
6:09
printing with that particular value this is another example having all almost
6:14
same character only be is different so it will be having a different location
6:19
and different values so this example I have highlighted over here so this is
6:24
about identifiers okay now what are operators Python divide the operations into all angle There are arithmetic operators assignment operators comparison logical identity membership and bitwise
6:39
We'll see them one by one. So what are arithmetic operations that we are already seen whenever you are doing addition
6:46
subtraction, multiplication, multiplication, modulation, modulus, exponential and floor division. So to perform on these operations, these particular symbols we can use in our coding
6:57
These are the examples of it. We'll see in those examples inside our Jupiter notebook as Y
7:02
Now to do comparison operations, you have equal to, not equal to, greater than, less than
7:08
greater than equal to or less than equal to. And these are different examples, how the operations are performed
7:13
In assignment operations, whenever you are seeing x equal to 5, you are assigning this 5 value
7:19
to x variable. When you are dividing plus equal to means, whenever you are doing x plus, sorry, I will give example maybe, your x plus equal to three means x equal to x equal to x plus three
7:36
This is same as these. Right. So these are assignment operator similar way minus equal to star equal to this is just kind of a shortcut to do your this kind of operations
7:46
So there are different assignment operators. Then whenever you are seeing a membership operation, that means that particular value is present or not
7:55
So when it is useful, for example, you have a list of hundred values, right
8:00
You do not know exactly what is there inside that. So list can have digit, can have strings, it can have any number of values, right
8:12
We'll see then in upcoming slides. but if you at all you wanted to check one in list that means this one value is present in this list or not whenever you wanted to check that means it will return a true in the sequence with specified values present in that object similarly not in operation and logical operation means and or of not so we whenever you are doing comparator comparison is in a bitwise comparison so for example when you are see x is less than five and
8:44
and x is less than 10, so that end operation will say if both of these values are satisfying
8:51
here, right? If these both values are satisfied, then it will give output as a true. Otherwise
8:57
it will give output as a fourth. That are the logical operators. Similar way, we have
9:02
identifier operator that is given by is or not is not. That means these are still written
9:11
If not, then it will then false. If at all inside your operations or inside your expression, there are multiple operations to be performed
9:21
So these are the priority. First you need to solve parentheses, then exponential, then error plus, then multiplication division, then addition and then so on
9:31
So these are the residence order in which you have to solve your expression
9:37
And then there are certain bitwise operators which we call. as end or x or not zero left shift or right ship so we will see this bitwise operations inside our diputern notebook as well so for example your i have taken two identifiers with
9:54
two values doing arithmetic operations of addition subtraction and then printing them
9:59
by just giving their values and whenever i am doing shift enter it will give me all the
10:05
operations values what does in nine plus four that is 13 9 minus 4 that is 5 and so on
10:11
whenever i am doing relational operations it will just give me what is greater what is less what is equal to right so output will be in terms of true or
10:20
falses like this right whenever i am doing logical operators and we also do uh output in terms of
10:28
true or pulses for example this is one whenever i am so telling logical operators true is
10:34
considered as one false is considered as zero whenever i am printing it out it will be false
10:39
true and false same way this one more or example because whenever I'm
10:46
saying one or one will be one and then bitwise operation means for example a
10:52
is 10 B is 4 it we convert 10 into bitwise 1 and 0 4 into 1 and 0 this way
11:01
for example 10 is 1 0 0 0 and whenever I am doing end operations that means multiply
11:08
So I am just multiplying each of these ones and zeros output will be zero so it should print zero as a out right whenever I am printing so whenever I am doing shift and enter it will be giving output as
11:26
Yes here see output is zero So this way our operations will be performed then we have assignment operators that means whenever you are just assigning and then
11:38
doing certain operations on it kind of a multiply addition light shift and left ship
11:44
these are the outputs and then identity operator will two values are equal it will you true
11:49
otherwise it will give you fall and that identity you are doing verifying with is keyword
11:55
i s so this was all the identifiers and operators inside a python to know what are the
12:02
different functions that are associated with particular glass you can use bIR method or
12:08
D-R function which is inbuilt function in Python. For example, with INT class, which is in build class in Python, whatever different methods that I can do, what are different operations that I can do
12:19
So I will do print DIR INT. So these are the different operations nest
12:25
So it will also have CSTR method, we'll also have init methods
12:31
All are this by default operations that we can perform on I&D class
12:37
So the example is instead of doing add plus operation, we can also use add method
12:43
Undesco and underscore and underscore is a magical method that we have already seen
12:48
So here I am just adding 10 with 5. So what should be 15
12:54
So that's the top. So these are all the opinions about identification operations
13:02
That's it about this chapter. I will see you in the next chapter