Python identifiers

In this article, you learn about python identifiers. In Python, identifiers are the names given to identify variables, functions, classes, modules, etc.

Identifiers are like the names that your parents gave you for your identification. Similarly, in python programming, a programmer can write identifiers to identify different objects.

Example 1: Python identifiers

Age = 27
A= 5
FirstName = “john”

In the above example “age”, “a” and “FirstName” are identifiers.

Rules to writing a valid python identifier

In python, there are some rules to write valid identifiers that are given below.

  1. The identifier can be letters, digits, and underscore (Aa-Zz, 0-9, and _)
  2. An identifier cannot begin with digits but can start with underscore and letters
  3. Keywords cannot be used as identifiers
  4. They are case sensitive which means “A” and “a” are two different identifiers
  5. We cannot use special symbols as an identifiers

Example 2: Some valid python identifiers

Students
Subject2
User_Name
logic
_age

Example 3: Some invalid python identifiers

Student Marks
2num
Your-name
!number