Lesson 5 / 47

Variables

Created on assignment, no type declaration.

Just assign

The type follows the value, and can change.

age = 25          # int
price = 9.99      # float
name = "Ada"      # str
is_active = True  # bool
x = 10
x = "now text"    # allowed

Multiple assignment

Handy for unpacking and swapping.

a, b, c = 1, 2, 3
a, b = b, a       # swap

Naming

snake_case for variables and functions; UPPER_CASE for constants (by convention only).