What are identifiers ?

Identifiers are a fundamental and extremely important concept in the Python programming language. Simply put, identifiers are used to give a unique name to various elements within a program, such as variables, functions, classes, modules, or other objects. Just as a person in society is identified by their name, similarly, any data or block in Python code is identified by its identifier.

Rules for Creating Identifiers

While naming any variable, function or class in Python, we must follow certain rules. If we ignore these rules, a SyntaxError occurs in the program. These main rules are as follows:
1. Starting : Identifiers Names are never declared with digits. For example = > 8number = 90 Python Interpreter gives error on declaring Identifiers Names with digits.
2. underscore(_) : Space is not used between Identifiers Names while declaring Identifiers Names. In Python underscore (_) is used in place of space in Identifiers Names, for example = > numbere_r = 90
3. case-sensitive : Since Python is a case sensitive language, Identifiers Names are case - sensitive, that is , Number, NUMBER, number are all three different Identifiers Names. These three variables have no relation with each other.
4. Keywords :Python language already stores such words whose meaning is already reserved for Python, hence Identifier Names cannot be given Keyword Names like => print = 90
5. Special Symbols :Special Symbols are never used in Identifier Names. Special symbols like : #, @, $ etc. On using such symbols, Python does not consider the Identifiers valid.

Naming Conventions

Apart from the rules, some global standards are followed to make the code clean and readable :
1. Always choose names that reflect their function. It is better practice to write age = 25 instead of a = 25.
2. Use underscores between words to name variables and functions, e.g. calculate_total_price.
3. The first letter of the name of classes should always be capitalized, e.g. EmployeeDetails.
4. If a name starts with a single underscore (_var), it indicates that it is a 'private' variable. Double underscores (__var) are used for 'strongly private' or name mangling.

roll_number = 101  
def greet():
    print("Hello World !")                                
                            

1. roll_number : This is the identifier of a variable. It follows the rules because it starts with a letter and uses an underscore (_) to separate words.
2. greet : This is the identifier of a function. Whenever we need to call this function, we will use this name.
This small example proves that any name we define ourselves in the code is the identifier.