Python: Variables

 Hello and Welcome to Blog #3, Python: Variables. This will introduce you to the concept of variables and how to use them in the Python programming language.


Variables are basically containers for storing values. They can store any values, such as integer values, string values, float values, and many others. You can also update the value of a variable after it has been set.

Here is an example of the following:

myVariable = 1

The variable is 'myVariable,' and its value has been set to 1. Now, we can change, or update, the value of the variable, 'myVariable.' Here is how this is done

myVariable = 2

Now, the value for the variable, 'myVariable,' has been updated to 2, so when it is called, or referred to, the value it has stored is now 2, whereas before we changed the value, the stored value was 1. 


The type of value can also be changed even after the variable's value has been set. For example, right now, the value of 'myVariable' is 2, an integer value, but we can change it to a string value. For example:

myVariable = 'Hello!'

Now, the value of 'myVariable' has been set to, 'Hello!' Now, when called or referred to, the value 'myVariable' contains is 'Hello!'


These are the basics of variables. Thank you for reading, and please look out for more posts. Please leave any comment or question in the comments section!

Comments