Python Identifiers

What is an Identifier?

Identifier means to identify; same is the meaning in programming language. Identifier is the name given to any entity such as variables, functions, classes, objects etc. in any programming language. It helps to differentiates one entity from another.

Python Identifiers

Identifiers play the same role in Python as explained above. Whichever name is given to Python variable, function, class, object etc. are called Python Identifier.

Example

myName = “Esha”

Here myName is a String variable with value “Esha”. Hence myName is an identifier because it is identifying the name of a String variable.

  • NOTE – Python is a case sensitive language. In the above example myStr will be treated is different than mystr. Note the highlighted character.

Python is case sensitive

Python Identifiers Rules

Every programming language has defined rules for identifiers which must be followed strictly for successful execution of any program. Same is applied to Python. Python has certain set of rules which shall be followed for defining Python Identifiers.

Python Identifier’s Do’s and Don’ts are listed below –

Do’s of Python Identifier’s –

  • Always give meaningful name
  • Can be the combination of lower case and upper case alphabets, numbers and ( _ )
  • Multiple words can be separated using an underscoreย 
  • Can be of any length
  • Can start with a letter or the underscore ( _ ) characterย 
  • Example – employeeName , employeeAge, employeeSalary, etc.

Don’ts of Python Identifier’s –

  • Can NOT start with a digit/ number
  • Keywords can NOT be used as identifiers
  • Can NOT use special characters such as !, #, @, %, $, *, ~ etc.
  • Example – 1Name, else, finally, @classVariable, etc.

Video explanation with demonstration can be checkedย here

Leave a Comment

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

Your email address will not be published. Required fields are marked *