Python Keywords And Identifiers

Python Keywords And Identifiers

The focus of this lesson is to understand the concepts of Keywords (Reserved Words) and Identifiers in Python Programming Language. In this lesson, we will discuss both Keywords and Identifiers one by one. So stick with me.

Python Identifiers

In Python Programming Language when we assign a name to a variable to identify it so we can call that variable by the name, in this case, an Identifier. We use it to identify our variable, class, function or other kinds of objects.

Python Rules:

It is strictly followed by Python that every identifier must start with any letter from (A to Z) or (a to z) or if you want you can use ( _ ) underscore symbol followed by one or more letters or numeric digits from (0 to 9). Check out the below identifier example. All of these examples are valid.

Recommended:  Python Environment Setup

In Python Language, the use of punctuation marks for example symbol @, $ and % for identifier name is not allowed. See the invalid examples below.

In Python, HelloWorld and helloworld are two different identifiers because it is a case sensitive language.

Here are some naming rules or you can say a naming convention for setting the names of identifier, class or functions which are as follows:

  • In Python whenever we want to declare a name for a class it must start with an uppercase letter. All other identifiers start with a lowercase letter.
  • If you want to make any identifier private starts its name with any letter with a single leading underscore indicates that the identifier is private.
  • If you want to make identifier double private you must start it with any letter and two leading underscores to show it as double private.
  • An identifier is called language-defined two trailing underscores are present at the end of the identifier.
Recommended:  Python Introduction: Features Of Python

 Keywords in Python Programming Language

There are some specific keywords or words in Python Programming Langauge that cannot be used as an identifier or variable they have an only specific function to perform. In the following table, all the reserve words have shown. Because Python is case sensitive language so one should type all the keywords as it is shown in the table below.

Recommended:  Python for Loop
breakexceptinraisepass
importelseassertyieldor
ifelif aswithnot
globaldelandwhilenonlocal
fromdefTruetrylambda
forcontinueNonereturnis
finallyclassFalse

As you are a beginner in Python Programming Language or if you don’t have any prior programming knowledge these words maybe cause confusion for you but as you go further deep in programming you will eventually get familiar to these words. So, keep going and keep programming until you succeed.

Jack Sparrow

Hay I am Admin Of This Website. I am very passionate about Computers and technology. This website is the result of my passion. I love to eliminate the barriers comes in the for seeking education. This website is the free source of learning about new technology and up to date knowledge.

This Post Has 2 Comments

  1. great work sir gee.

    1. Thanks.

Leave a Reply

Close Menu