Variables are given to data that needs to be stored and manipulated in a program. For example, to store the age of a user, we will name the data user_age and define it as:
user_age = 0
After the variable user_age is defined, the program will allocate a certain area of the computer's storage to store the data. This data then can be accessed and modified by referring to the variable's name.
Initial values, such as 0, need to be given to declare a new variable.
We can also define multiple variables in one go, such as
user_age, user_height_cm = 25, 170
and is equivalent to
user_age = 25
user_height_cm = 170
No comments:
Post a Comment