Check out the Spoken English Course. Free Course with Free Certificate
Hello guys. Welcome to Learnvern.
In the last topic we saw the basic syntaxes of Python in which we saw basic inbuilt functions and their use.
Today we are going to learn about Keywords, what exactly are keywords, what’s their use & how many keywords are available in Python.
First & foremost, what are Keywords?
Keywords are the reserved words in Python which are provided by Python...they can’t be used for users’ use.
For example, you can’t use the variable’s name as a keyword.
Keywords such as If, float, in, import, and, else, if else...all of these are the keywords of Python so you can’t use these names in variables, you can’t use them under function…
Suppose you made a function like def and if...def - if...then you can’t use that “if” as the name of your function.
I mean to say that the keywords are predefined beforehand and they are already reserved in every language.
Same goes for Python. The keywords are already reserved & you can not use them according to your need.
You can only use them in relation to their work. Okay?
Suppose it’s If Else. you can’t use If Else as a variable’s name. Understood?
It is a reserved word under Python, you can’t use it according to your need.
There’s this list of Keywords such as False, Await, Else, Import, Pass, None, Break, Except...these are among the reserved keywords of Python.
Meaning you can’t use them.
There is no practical for Keywords but I’ll still explain to you how they are reserved under Python.
I’ll now show you practically.
Suppose I type here “And” which is a reserved Keyword. And I wrote it this way.
Now I’ll print And.
You can see it alerted to a syntax error calling it invalid syntax.
Why? Because you cannot use And as a variable’s name.
Because it is a particular keyword in Python.
Suppose I wrote True here. And I changed it here to True.
It displayed cannot assign True meaning you can’t ever assign it as it is a keyword.
It is a reserved word under Python so you can’t use it.
But if you want a particular list, how will you write it?
Write down the function Help. Write down what help you want?
I want the help of Keywords.
As soon as you pass it, you'll get a whole list of keywords which are reserved under Python. Clear?
You can’t use these keywords as names for your variables, as names of your functions or even as a name for your class.
All of these are reserved.
In the next topic we will see Datatype under which we will see data types of Python.
Okay… thank you.
Have a friend to whom you would want to share this course?