Variables in Python | Tokens in Python | Python Tutorial | Tokenize Python

So in this python certification series we will learn about Python variable and Python token.

Let's discuss them one by one.

So our first topic is Python variable.

How do you think the values assign.

Well for assigning the values there are two different methods, firstis assigning single value to a variable and the next is assigning multiple values to a variable.

So let's start with assigning single value to a variable.

You know what.

Unlike Java orC++ you don't have to add any data type for a variable.

Just specify the name of the variable.

For example a=10.

So depending on your data, python will automatically detect thedata type of a variable.

Which in this case is integer.

Let'ssee other example suppose we have a name as a victor.

So python will automatically detectthat this name variable is of database string since it stored the string value.

Next wehave salary as two thousand point two three.

So since 2000 point two three is nothing buta floating type so automatically python will detect that salary is of our database.

float.

You don't have to specify a data type to a variable.

Let me just show you this example in our jupiter notebook.

For example I need to store an integer value.

So I'll name a variable like a equal 10 a is integer and I'm not specifying any data type for it.

Right? hit enter.

Since no error is appearing so I guess It's correct.

Butwhat if I just write int a=10.

As you can see and gave me an invalid syntaxso you cannot use any data type before a variable all right.

Next what if I want to store astring variable.

Just like.

Name equal John.

similarly for our floatingdata type salary or any variable name equal.

Two thousand twenty three dot two three four.

As simple as that.

So now that you have learned how you can assign a value to a variable let'ssee how you can have multiple assignment to a same variable.

So.

Let's suppose you areassigning three variables as a equal 10.

B equal 10 and again C equals 10.

So here we havethree variables and what you have to do you have to assign the same value to all of them.

So instead of assigning value one by one what you can just write.

You can just write a equal B equal c equal 10.

Andit will be executed without any error.

Fine.

Now this was simple.

Now what if you have toassign different value to each variable.

For example I have a variable as x equal 20.

Y equal thirty and Z equal 40.

So in this case what you can do for multiple assignmentyou can just write X comma Y comma Z.

Equal 20 comma 30 comma 40.

It's as simpleas that.

Now let me just print any of the two variables and check if we are corrector not.

So let's print y and let's print a.

So we got the output as 30 and 10.

Y=30 and a=10 even if you want you can just check by updating thevalue like a equal B equals c equal 20.

And this is make it something else like 40 & 50.

Andnow print the value of y and a So you'll get the value us 40 20.

All right.

So this was about the assigning single value to a variable.

We also learned about assigningmultiple values to a variable.

A Equal B equal C equal 10 In this example we already did right.

And we got the output.

As 20 10.

So now that you know how you can assign value to a variable.

So let's move ahead and start our discussion with some basics of Python.

So let's startwith Python token.

So what exactly is this python Token.

Python token is the smallest meaningful componentor it is a very basic component of the source code.

The characters are categorized as one of the four class of tokens that describe their functions.

It can be a keyword it can be a literal.

It can be identifier or it can be an operator.

Fine.

So let's discuss them one by one starting with keyword.

So what are these keywords.

Well these keywords are some sort of result words which are designed for a specific purpose.

You cannot use a keyword as a variable name or an identified name.

Some of the keywordsin Python include For, If, Del, break continue.

true, false etc.

You cannot use them asa your variable.

These words in python have a specific purpose and have a specific meaningto it.

Let's move ahead.

Next is the identifier.

Well it is the name that you give to a variable or to your function or to your class.

For example ifyou are defining a variable as=10 then then the word a or the variable a is definingthe identifier.

Well before you start naming your variables or methods of class.

You must know that there are certain set of rules or guidelines for naming and identifying.

Let's see them one by one.

So the first one is no character except the under scope canbe used as an identifier.

So what does that mean.

Let's see.

So youcannot have a variable name as at@ One two three equal something any value.

Youcannot have a variable name like this it will throw you in error.

Or you cannot even havea variable like.

at.

We equal twenty even this will throw you in an error.

But instead If you write 80 underscore we this would be perfectly fine.

Next is keyword should not be used as an identifyer name this i told you earlier also It's like if you are mentioning some keywordslike F equall 10 obviously this will tell you an error.

Or you are writing while equal 10.

Then this will give you an error.

You cannot use any keyword as a name of an identifier.

I.

E.

a name of a variable, a class, object.

Or a function.

Next is Python is case sensitive.

That is Var with capital V and var with small v are two different identifier.

Letme show you this.

Suppose I mentioned a equal 20 and capital A equal 10 So what do you think the value should be ifI print a.

Would it be updated to 10 or what would be same as 20.

Well let's see.

So theoutput is 20.

So it means that Small a or the a in smaller case and A in uppercase bothare treated differently in Python.

So let's move ahead.

Next.

And the last one is firstcharacter of an identifier can be a character underscored but not Ed.

Well what does thismean.

When to be equal then does it all.

1 2.

Or.

Or 41 and that eight are a C equals something.

Given this is wrong.

But what you can do instead you just specify underscore before this.

Anda score of 41 a C without the agreed part as no special character other than unlesscode is allowed.

Equal then.

So this thing would be accepted without any error.

Fine.

So this was all about the identifiers.

Next comes the liberals.

Well latrines are theconstant use in Python.

Or you can see that liberals are the data given in a variableor a constant.

Basically there are four different types ofliquids.

String laterals pneumatic lateral bowling little and special little.

Let's havea look at them one by one.

Starting with string liquids.

Well you can create a string literaljust by enclosing a text within the code.

Both single and double quotes are allowedin a string letter.

For example.

You can have a variable as Name one.

Equal.

W codes.

John.

And you can even have a variable as named to equal within single code.

John.

Or.

MaybeJames.

Aren't getting any error right.

So since youare not getting any error in the output so it verifies that you can use both the singleand W codes and string literal.

Okay.

Now what if you have multiple line input.

So howare you playing Dr.

Let's see from multiple line input.

Might.

Be.

Not.

Equal.

So allyou need to do is mention three single codes.

Just three.

And after that start writing likestring one.

And two different line string to.

Line three string three.

And again you two ended using three chords.

Fine.

Executed.

You won't get any error.

And if you're playing the mighty line.

You get.

The output as.

SDR one still two as yet three and three different lines.

Let's get backto our tutorial.

So what was our input name one John.

Namely equals James Frank.

Nameone name too.

And we got the output.

Yeah we discussed this.

We have a mighty line thingwithin a codes.

We had a mighty line thing and what you needed the output and three differentlines.

So yeah you got it using three quotes.

Fine.

So this was about D string literal later in this session we'll see what are the radiusof the function you can perform on these string and.

Using some of the bytes existing library.

For now let's move ahead and let me give you an overview of numerically.

So what are thesenumerical entrance.

And new medical school is a character stringwhose characters are selected from the budget's zero tonight.

It consists of four assignedgotta go.

It can be either positive or negative.

Or it can even convenor decimal point.

Wellif the little contains no decimal point then it means that it's an integer.

If your numberis too long and we are capital L or small L at the end of the number.

It makes it a long number.

Or if the liquidcontains a decimal point it becomes a float.

But yes remember that you can only use onedecimal point in a number.

Have you ever seen a number with more thanone decimal point.

Never.

Right.

Well just for the FAA I'm not talking about the IP Ilike.

By the way in Python the value of integers not restricted by the number of but.

It canexpand to the limit of the available memory.

And since the value of the integer dependson the available memory.

So no special arrangement was made in Pythonfor storing large number.

So any doubt up the this potion.

Well if youhave these added and the comments section below.

So moving on ahead.

Next we have isthe boolean literally.

Well these boolean literal have just two values either true orfalse.

Well remember that both these true and false are also keyword.

So you cannotuse them as an identifier.

Now I generally use when we are dealing with some conditionwhose outcome is either true or false.

All right.

So this was a body boolean literally.

Next we how is this special little.

Will Python has just one special lateral asnot which is used to specify the field that is not created.

Well if you are from a programmingbackground or you just have a basic knowledge about C C++ or Java.

I think you must haveheard about the keyboard.

All right.

Well if yes then this knowledge is nothing butthe equivalent of null keyword and C C++ or Java.

So I hope that you guys have understoodabout a little.

Bit.

There are many cases where you can use none.

Let's see an example.

It's a self-explanatory example.

Just go throughit will proceed.

All right.

I think needs to be explained in this.

So this was all forthis session we learned about various Biden media bills and different Byron Dogan Slatekeywords literally identified.

So one of the Biden Dogan not as operate asmissing up here.

So we'll be covering it in the next session.

Thank you.

Source: Youtube