What is Identifiers,Variables and keywords in Python?

Python Identifiers

Python Identifiers refers to name of various program components which is used to make the entire program is called identifier. An identifiers is a smallest identifying unit in the program. It denotes various entities like variables, Data types, Labels, Subroutines or function, packages and so on.  It must be unique and also identifiers names must be different from keywords. You cannot use 'continue' as an identifier because continue is a keyword.

Rules for making identifiers in Python

1. To form an identifier, use a sequence of letters either in lowercase (a to z) or uppercase (A to Z). However, you can also mix up digits (0 to 9) or an underscore (_) while writing an identifier.
For example – Names like rollnum, Class_1, and School_10th_reg_no are all valid identifiers.
2. You can’t use digits to begin an identifier name. It’ll lead to the syntax error.
For example – The name, 0roll is incorrect, but roll1 is a valid identifier. 

Python Variables

Python variables are used to store values which means reserved memory locations to store values. When you create variable then it means that you reserve some space in memory.

Some important fact about python variables:-

1. Variables don’t require declaration. If you don't declare variable type then it is implicitly declared at run time. It means that python variables are dynamically typed.
For example –
userid = 10

2. Variables names can be alphabet, Underscore and digit but it can not be started with digit.


valid variable names:- _A, A12_B, a

invalid variable names:- 1A, 12a, 1_A 

3. The above expression will lead to the following actions.
  • Creation of an object to represent the value 10.
  • If the variable (userid) doesn’t exist, then it’ll get created.
  • Association of the variable with the object, so that it can refer the value.
The variable ‘userid’ is a reference to the value ’10’. Please refer to the illustration shown below.


| ~~~~~ | ----- ~~~~~~~~~ ------- ****
( userid ) ----- Reference ------- ** 10 **
| ~~~~~ | ----- ~~~~~~~~~ ------- ****
Variable ----- ~~~~~~~~~~ ------- Object
4. Whenever the expression changes, Python associates a new object to the variable for referencing that value. And the old one goes to the garbage collector.


>>> userid = 10
>>> id(userid)
>>> userid = 11
>>> id(userid)
5. For optimization, Python builds a cache and reuses some of the immutable objects, such as small integers and strings.
6. An object is just a region of memory which can hold the following.
  • The actual object values.
  • A type designator to reflect the object type.
  • The reference counter which determines when it’s OK to reclaim the object.
7. It’s the object which has a type, not the variable. However, a variable can hold objects of different types as and when required.

Python Keywords

Python keywords are reserved word which is already defined to interpreter of python. And these python keyword is not used as variable names.

There are 33 keywords in Python 3:-

['False', 'None', 'True', 'and', 'as', 'assert', 'async', 'await', 'break', 'class', 'continue', 'def', 'del', 'elif', 'else', 'except', 'finally', 'for', 'from', 'global', 'if', 'import', 'in', 'is', 'lambda', 'nonlocal', 'not', 'or', 'pass', 'raise', 'return', 'try', 'while', 'with', 'yield']

we can easily see the list of python keyword in python 3 IDLE by typing the given script:

Keywords/Python Keywords/Python/Python

'True', 'False' and 'None' are keywords having its first letter capital and other are small, except these three keywords all are started with small letter.

There is no keyword like do while and switch as we have learn in C, C++.

Reference Books for Learning Python


Also share your knowledge about python to improve our knowledge and this post too.

Read also

Tags: Python keywords, Python Variables, Python Identifiers, Types of keywords in python, Examples of Identifiers in Python, Examples of variables in Python, how to declare Variables in Python, How to defines the name of variables, restriction in defining Python Variables names, Identifiers, Variables, Keywords


  1. Thanks
    informative post about variable identifier and keyword.
    Best IDE for C programming

  2. All these codes were always difficult for me until the moment, when I have found a good teacher. He explained me how it all works in quite a short period.

  3. According to my experience, Python is the best programming language. Even Java is not as good as Python. Though, everyone has his own opinion.

  4. The development of artificial intelligence (AI) has propelled more programming architects, information scientists, and different experts to investigate the plausibility of a vocation in machine learning. Notwithstanding, a few newcomers will in general spotlight a lot on hypothesis and insufficient on commonsense application. machine learning projects for final year In case you will succeed, you have to begin building machine learning projects in the near future.

    Projects assist you with improving your applied ML skills rapidly while allowing you to investigate an intriguing point. Furthermore, you can include projects into your portfolio, making it simpler to get a vocation, discover cool profession openings, and Final Year Project Centers in Chennai even arrange a more significant compensation.

    Data analytics is the study of dissecting crude data so as to make decisions about that data. Data analytics advances and procedures are generally utilized in business ventures to empower associations to settle on progressively Python Training in Chennai educated business choices. In the present worldwide commercial center, it isn't sufficient to assemble data and do the math; you should realize how to apply that data to genuine situations such that will affect conduct. In the program you will initially gain proficiency with the specialized skills, including R and Python dialects most usually utilized in data analytics programming and usage; Python Training in Chennai at that point center around the commonsense application, in view of genuine business issues in a scope of industry segments, for example, wellbeing, promoting and account.

    The Nodejs Training Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training


Powered by Blogger.