Easy Understandable -‘Variable’

Sandeshgaikwad
3 min readSep 13, 2023

--

Hello all,
Sandesh Here again, In this article we will learn what is ‘variable’.
We all knows Python is one of the most simple and easy programming language nowadays. The ease of access and readability makes Python ideal for beginners who want to learn the basics of coding. As a Python programmer, we need to understand what is variables.

lets first Discuss what is a variable in Python?
Vriable is a memory block in RAM.
Its just a name that we have assigned to the perticular value.
They can be used to store data types. this practice is easier than remembering all the different values. so lets see how to create variable.
before creating variables we should need to understand some rules.”
=>
Variable names can only contain letters, numbers, and underscores.
=>Variable names cannot start with a number.
=>Variable names are case sensitive (vev
_code_lab & vev_Code_lab are not same).

Lets Create a Variable in Python.
By using the assignment operator we can create variable.
example
in following screenshot we can see we assigned value of 100 to the variable ‘a’.
by running print built-in function we can see this.

In this example we can see the string datatype value.
string datatype “Sandesh_Gaikwad” is assigned to the ‘
name’

Yes we can reassign a Variable.

We can reassign values of different types to the same variable without issue.
In this example we can see we first assigned int value 100 tho the variable ‘a’
and then we used same variable ‘a’ to get assigned by different value which is string datatype “i love india”

Yes we can assign Multiple Variables at Once
example
we can see here we assigning int,float and string datatype at once

Yes we can swap the values of variable without declaring.

In this example we can see we assigned 50 and 100 to x and y.
in next image we can see x and y swapping their pointing value with each other.

Numbers of variables and Numbers of Values
In follwing example we can see
here we assign value 10 to the a ,
value 20.222 to the b ,
value -33 to the c
value school to the d
and value building to the e
it dossen’t shows any error because the numbers of variables and values are same.

but if we provide different variable and value number,this error will occur.
ValueError: not enough values to unpack (expected 5, got 4)

So this is the article about what is variable and how to create it.There is more to do with variables lets meet on next article.
If you find this information is useful then please like it and if any suggestions are there please put those in comment.
Thanks
#vevcodelab
@sandeshgaikwad

--

--