Читать книгу Learn Python quick - Jens Braun - Страница 9
What are variables?
ОглавлениеVariables are names given to data that we need to store and manipulate in our programs. For instance, suppose your program needs to store the age of a user. To do that, we can name this data userAge and define the variable userAge using the following statement.
userAge = 0
After you define the variable userAge, your program will allocate a certain area of your computer's storage space to store this data. You can then access and modify this data by referring to it by its name, userAge. Every time you declare a new variable, you need to give it an initial value. In this example, we gave it the value 0. We can always change this value in our program later.
We can also define multiple variables at one go. To do that simply write
userAge, userName = 30, ‘Peter’
This is equivalent to
userAge = 30
userName = ‘Peter’