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.
- The identifier can be letters, digits, and underscore (Aa-Zz, 0-9, and _)
- An identifier cannot begin with digits but can start with underscore and letters
- Keywords cannot be used as identifiers
- They are case sensitive which means “A” and “a” are two different identifiers
- 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