A Detailed Tutorial on Python Variables:
Our previous tutorial explained us about Python and its Installation process in detail.
In this tutorial, we will have an in-depth look at the Python Variables along with simple examples to enrich your understanding of the python concepts.
Read through our Entire Python Series for a clear understanding of the various concepts involved in Python.
What You Will Learn:
Watch the VIDEO Tutorial
Role and Importance of Variables in Python
A variable means holding a value or reserving memory location to store values. In variable, you can store any kind of values by using appropriate data types.
In Python, variables do not need a declaration to reserve memory space. The “variable declaration” or “variable initialization” happens automatically when we assign a value to a variable.
How to Declare and use a Variable
To declare a variable we use “=” to assign the value to a variable.
We will declare the following variable and print it.
Number= 25 Name = “Kiran” B= 3.5 print (Number) print(Name) print (B)
Re-declare a Variable
We can re-declare a variable at any point of time even after you have declared it once.
Name = Python print(Name)
In Python, we can assign the same value to multiple variables at once.
x = y = z = "SoftwareTestingHelp" print (x) print (y) print (z)
We can also assign multiple values to multiple variables.
a, b, c = 5, 3.2, "Hello" print (a) print (b) print (c)
Hope you would have understood the concept of Python Variables in detail from this tutorial.
Watch out our upcoming tutorial to know more about Python Data Types!!