← All sections

Module 2 · Python data types, variables, operators, and basic I/O operations

Variables

Give your data a name so you can store it, reuse it, and change it. Named boxes that hold a value — the memory your programs run on.

Begin lesson 1 →
  1. 1Variables — data-shaped boxesA named box that holds a value of any type.
  2. 2Variable namesThe rules and conventions for naming your boxes.
  3. 3How to create a variableAssignment: put a value into a name with =.
  4. 4How to use variablesUse the name and Python fills in the value.
  5. 5Assigning a new valueChange what a variable holds — even using its old value.
  6. 6Solving simple problemsPut variables and operators together to compute a result.
  7. 7Shortcut operatorsx += 1 and friends — shorthand for updating a variable.
  8. 8QuizCheck your understanding of variables.