Variable is a named location used to store data in the memory. It is helpful to think of variables as a container that holds data which can be changed later throughout programming.

For example,

x=42

y=42

https://files.cdn.thinkific.com/file_uploads/151938/images/415/a0c/56f/2020-10-21_(8).jpg

Here as you can see, the variable names stand for the memory location. It's like the two shoe boxes, which you can see in the picture. These shoe boxes are labelled with x and y and the corresponding values are stored in the shoe boxes. Like the two shoe boxes, the memory is empty as well at the beginning.

Examples of Variables

numberInput = -56
our_Website = "wiselywise.com"
newValue = 1.667

In the code block above, there is variable name numberInput with the value of -56. So it is storing the value of -56 in the container with a name of numberInput. Similarly for other examples the value is stored in the variable name no matter the type of the value.

Type of the variable

pi = 3.14
print(type(pi))

In the above code, the type of the variable is found by using the type keyword and passing the variable as a input to find the type of the variable. We have not covered datatypes but just remember we can use type to find the data type of the variable.

Manipulating variable values

x = 123
x = "akatsuki"
print(x)