Identifiers

In programming languages, identifiers are names used to identify a variable, function, or other

entities in a program. The rules for naming an identifier in Python are as follows:


1. The name should begin with uppercase or lowercase alphabet or an underscore sign (_).

This may be followed by any combination of characters a–z, A–Z, 0–9 or underscore (_).

Thus, an identifier cannot start with a digit.


2. It can be of any length. However, it is preferred to keep it short and meaningful.


3. It should not be a keyword or reserved word.


4. We cannot use special symbols like !, @, #, $, %, in name of an identifier.


For example, to find the average of marks obtained by a student in three subjects, choose the

identifiers as marks1, marks2, marks3 and avg rather than a, b, c, or A, B, C.


avg = (marks1 + marks2 + marks3)/3


Similarly, to calculate the area of a rectangle, use identifier names, such as area, length, breadth

instead of single alphabets as identifiers for clarity and more readability.


area = length * breadth