September 2026
1051 pages
35h 4m
English
In Python, you can assign a name to a value like a number or a string. For this purpose, the name is written on the left and the corresponding literal on the right of an equal sign. Such an operation is referred to as an assignment.
>>> name = 0.5>>> var123 = 12>>> string = "Hello World!">>> lst = [1,2,3]
The values associated with the names can be output later or used in calculations by entering the name instead of the respective value:
>>> name0.5>>> 2 * name1.0>>> (var123 + var123) / 38.0>>> var123 + name12.5
It’s also possible to assign a name to the value of any expression, for example to the result of a calculation:
>>> a = 1 + 2>>> b = var123 / 4
The part to the right of the equal sign is always evaluated first. For ...
Read now
Unlock full access