Python: Identifiers

                   Python: Identifiers

Python Identifiers:

All the variables, class, object, functions, lists, dictionaries etc. in Python are together termed as Python Identifiers. Identifiers are the basis of any Python program. Almost every Python Code uses some or other identifiers.

{tocify} $title= {Table of Contents}

Rules for using Python Identifiers:

  •          An identifier name should not be a keyword.
  •          An identifier name can begin with a letter or an underscore only.
  •          An identifier name can contain both numbers and letters along with underscores  (A-z, 0-9, and _).
  •  All succeeding characters must be alphabets or digits.

  • The first character must be an alphabet (uppercase or lowercase) or can be an underscore.
  • An identifier cannot start with a digit.
  • No special characters like!, @, #, $, % or punctuation symbols is allowed except the underscore”_”.
  •          No two Successive underscores are allowed.
  •          An identifier name in Python is case-sensitive i.e., sum and Sum are two different identifier.

Example of valid identifier names are sum, _my_var, num1, r, var_ 2, First, etc.

Examples of invalid identifier names are 1num, my-var, %check, Basic Sal, H#R&A, etc.

Post a Comment (0)
Previous Post Next Post