KEYWORDS IN PYTHON

KEYWORDS IN PYTHON

Now, we are going to learn about a very interesting, and important concept, which we are going to be using from time to time, and the concept is python keywords. So, the very first question, and a pretty obvious question should be that what are keywords?

Basically, if you are already familiar with the term keyword from some other programming language, then it would be very useful for you here, but since we are not assuming anything over here, and even if you are new to the concept, we are going to study it here from scratch.

So, keywords are nothing but words, whose meaning is already understood and defined, and they cannot be used other than for their purpose. We can also say that the keywords have some special meaning. The keywords are also called as reserved words, and you can understand them as the words that are reserved and are used by the python interpreter to understand the program.

The simple thing is that we cannot use the keywords anywhere else, other than where they are supposed to be used.

Now, when we will be writing different programs ahead, we will surely encounter different keywords, and their uses in our programs. But the thing is that what are the different keywords that we have with us? Or what are the different keywords in python? Well, it depends on what version of python that you are using. However, you can simply search for all the keywords for your version of python. Here is how you can get the keywords for your version of python. Follow the given steps to get the keywords –

  • First of all, launch the terminal (or command prompt)
  • Just type python on the terminal and hit enter.
  • After you do this, you can see some related information, like the version of python you have installed, and some other instructions.
  • Now, you have to type help on the command prompt, and hit enter.
  • After that, you receive another message, and then you have to type help(), for an interactive help.
  • After you do this, the help utility is started. This is where we are going to get the list of keywords in our version. Here, we just have to type keywords, and then hit the enter key.
  • Once you enter “keywords” in the help, and hit the enter key, you get the keywords on the screen.

Following the above steps, you can easily get all the keywords that are available for the version of python, that you are using. We are also listing a few keywords, which we are going to use from time to time.

Noneclass
foror
ifelif
defcontinue
breakreturn
passimport

And there are a lot of other keywords.

So, the bottom-line is that keywords, or the reserved words are some words, whose meaning is already understood and defined, and they cannot be used anywhere else other than where they are supposed to be used. Again, as we are going to move forwards, we are going to make use of different keywords for doing different things. For example, we are going to use the keyword “if”, when we are going to deal with conditional statements, we are going to use the keyword “class”, when we are going to learn about object oriented programming, and we are going to make use of the for keyword, when we would learn and implement the concept of looping, and there are a lot of keywords that would be used for different things from time to time.