Variables

📦 Ready to store some data? Variables are your way of labeling information so you can use it later.

Assignment

Assign values to variables.

Naming

  • Must start with a letter or underscore
  • Cannot start with a number
  • Can only contain alphanumeric characters and underscores
  • Are case-sensitive

Reassignment

Update a variable’s value.

Multiple Assignment

Assign values to multiple variables in one line.

Dynamic Assignment

Variables can change type at runtime.

Best Practices

  • Use meaningful names (e.g., total_price instead of tp)
  • Stick to lowercase with underscores for readability (snake_case)
  • Avoid using Python keywords as variable names (e.g., class, list, print)
  • Use type() and print() to debug variable during development.

Common Errors

Some frequent errors encountered when dealing with Variables in Python.