all Python 3Input & outputterm
Variables
variables
Named places in memory that hold values. Python variables are dynamically typed — the type comes from the value, not from a declaration.
Syntax
имя_переменной = значение
A name is a label attached to an object, not a box holding a value: b = a copies nothing, and if the object is mutable (a list, a dict), a change made through one name is visible through the other. Reading a name that was never assigned raises NameError — not None, not zero. In multiple assignment the number of names on the left must match the number of values on the right, otherwise you get ValueError.
Examples
x = 10 # целое число
pi = 3.14 # float
greeting = "Привет" # строка
a, b, c = 1, 2, 3 # множественное присваивание
a, b = b, a # обмен значений без temp
x += 5 # x = x + 5 → 15 (составное присваивание)
del x # удаление переменной
See also
Open in the full glossarydocs.python.orgReport an inaccuracy