Q.

What are Identifiers? Write their naming rules.
What are Identifiers? Write their naming rules.

Chapter-2 | ਪਾਇਥਨ ਪ੍ਰੋਗਰਾਮਿੰਗ ਸਬੰਧੀ ਮੂਲ ਧਾਰਨਾਵਾਂ | Basic Concepts of Python Programming

The names given to program elements such as variables, functions, etc. are called identifiers. To define the names of elements in a program, we have to use the following naming rules:

  • Identifiers must be made up of a combination of lowercase (a-z) or uppercase (A-Z) alphabets, digits (0-9) or underscore (_).
  • Identifiers cannot start with a digit.
  • No keyword can be used as an identifier.
  • No symbol or special character other than underscore (_) can be used in identifiers.
  • Identifiers can be of any length; there is no restriction on the length of identifiers.
  • Python is a case sensitive language. Therefore, the case of the alphabet is important in naming identifiers.

For example: roll and ROLL are two different identifiers.

  • Whitespaces cannot be used in an identifier.

The names given to program elements such as variables, functions, etc. are called identifiers. To define the names of elements in a program, we have to use the following naming rules:

  • Identifiers must be made up of a combination of lowercase (a-z) or uppercase (A-Z) alphabets, digits (0-9) or underscore (_).
  • Identifiers cannot start with a digit.
  • No keyword can be used as an identifier.
  • No symbol or special character other than underscore (_) can be used in identifiers.
  • Identifiers can be of any length; there is no restriction on the length of identifiers.
  • Python is a case sensitive language. Therefore, the case of the alphabet is important in naming identifiers.

For example: roll and ROLL are two different identifiers.

  • Whitespaces cannot be used in an identifier.