Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
82 views

Python Identifiers

In Python, an identifier is a name given to variables, functions, classes, and other entities to uniquely identify them. Identifiers can contain letters, numbers, and underscores, must start with a letter or underscore, and are case-sensitive. Keywords like if and else cannot be used as identifiers, and double underscore names have special meanings.

Uploaded by

vinayvbugade
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
82 views

Python Identifiers

In Python, an identifier is a name given to variables, functions, classes, and other entities to uniquely identify them. Identifiers can contain letters, numbers, and underscores, must start with a letter or underscore, and are case-sensitive. Keywords like if and else cannot be used as identifiers, and double underscore names have special meanings.

Uploaded by

vinayvbugade
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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