Variable in Python3
The instructions that you typed in will be stored in one
area of memory, but also the data that it’s going to work on, the variables
that you’ve typed in, will be stored somewhere else in memory. So the variable,
the name that assigned is just really a way to give a meaningful name to an
area of memory into which we can place certain values.
There are few rules to keep in mind when you actually
created them. The actual name has to start with either a letter, it could be
upper or lower case, or an underscore but we can’t start that with the number.
We can use numbers in our variable names, just not as the first letter.
Now the other important thing to consider here is that we
could type a variable name called ‘Myname’ with uppercase M and that’s different
and distinct to lowercase ‘myname’ variable.
Now, in terms of the memory allocation, it happens at the
point when you’ve initialized it. In other words once you’ve typed in the
variable name and put an equal and then the value, at that point, python will
allocate the space for that in the computer’s memory.
Now, use the print statement to print some out.
Comments
Post a Comment