Declare a Variable in Python

In Python, you declare a variable by writing the name, followed by = and the value:

score = 0
  • score — the name you use to refer to this variable
  • 0 — the initial value assigned to it

There is no need to specify a type. Python figures out the type from the value on the right.

Naming Rules#

  • Names can contain letters, digits, and underscores.
  • Names cannot start with a digit.
  • Names are case-sensitive: choice and Choice are different variables.
  • Use clear, descriptive names that reflect the value being stored.

Resources#