Editor settings

General settings

Save settings

Learn to program with Python

Naming Convention for Variables #

The naming convention for variables may differ in each programming language. In Python, variables can have English letters, both lowercase and uppercase a-z A-Z, numbers 0-9, and underscores _. However, variable names cannot start with a number. Examples of valid variable names are:

age = 1
Age = 2
aGe = 3
AGE = 4
a_g_e = 5
_age = 6
age_ = 7
_AGE_ = 8

Examples of invalid variable name:

1099_failed = False
There are four naming conventions for variables:
  1. Snake Case, which uses an underscore _ between words, such as student_name, company_phone_number
  2. Kebab Case, which is similar to Snake Case but uses a hyphen - instead of an underscore _, such as student-name, company-phone-number
  3. Camel Case, which uses the first letter of each word capitalized, except for the first word, such as studentName, companyPhoneNumber
  4. Pascal Case, which is similar to Camel Case but starts with a capitalized first letter for the first word, such as StudentName, CompanyPhoneNumber

In Python, snake case is a convention used for naming variables.


Exercise #

  • Change the variable name from 1099_failed to year.
Output will be displayed here