Python Tutorials · Python Variables

Variable Names

Learn all about Variable Names in this comprehensive tutorial.

5 min read beginner
  • A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).
  • Variable names with more than one word can be difficult to read.
  • Each word, except the first, starts with a capital letter:
  • Each word starts with a capital letter:
  • Each word is separated by an underscore character:

Variable Names

A variable can have a short name (like x and y) or a more descriptive name (age, carname, total_volume).

Rules for Python variables:

  • A variable name must start with a letter or the underscore character
  • A variable name cannot start with a number
  • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable names are case-sensitive (age, Age and AGE are three different variables)
  • A variable name cannot be any of the Python keywords.
python
python
Note: Remember that variable names are case-sensitive

Multi Words Variable Names

Variable names with more than one word can be difficult to read.

There are several techniques you can use to make them more readable:

Camel Case

Each word, except the first, starts with a capital letter:

Pascal Case

Each word starts with a capital letter:

Snake Case

Each word is separated by an underscore character:

Module quiz

2 questions
1

Which of the following is true about Variable Names?

2

What is the most common pitfall when working with Variable Names?

Answer all questions to submit.