Naming convention for a variable

One of the cool features of Python is to not declare the data type of variable. This feature in itself is very useful for beginners or even for an experienced person. However, there are some naming conventions which should be kept in mind while naming a variable. Some of these are mentioned below.

  • Variable names should start with an alphabet. e.g. 'age'
  • It is recommended not to start a variable name with a capital letter. i.e. It is better to name the variable as 'age' rather than 'Age'. This is not mandatory but is a good practice.
  • It should not contain any special characters like $ @ ! ( ) & ^ except underscore '_'. e.g variable name 'python#variable' is not acceptable but 'python_variable' is acceptable.
  • A variable name can contain numbers but should not start with the number. e.g variable name '1_python' is not acceptable but 'python1' is acceptable.
  • Use an underscore at the start of the naming to hide that variable. e.g variable name '_python' is acceptable. Using such a naming convention makes it difficult for other users to find that variable.