You are on page 1of 1

In Python, an identifier is a name given to entities like variables, functions, classes, modules, etc.

It
helps in uniquely identifying these entities in a program. Here are the rules for creating identifiers in
Python:

Allowed Characters:

It can include letters in lowercase (a to z) or uppercase (A to Z).

It can include digits (0 to 9).

It can include the underscore character (_).

Rules for Naming:

Identifiers should start with a letter (a-z, A-Z) or an underscore (_).

The subsequent characters can be letters, digits, or underscores.

Python is case-sensitive, so "myVar" and "myvar" are different identifiers.

Reserved Words:

Avoid using Python keywords as identifiers, as they have special meanings. For example, if, else,
while, for, class, def, import, etc.

Special Identifiers:

Identifiers starting and ending with double underscores (__) are reserved for special use in Python.
For example, __init__ is used as a special method in classes.

Convention:

It's a convention to use lowercase names for functions and variables, and uppercase names for
classes. If an identifier name consists of multiple words, it's common to use underscores to separate
them (snake_case).

You might also like