Vriables are the names that are used to refer to a specific memory location. Variables are also known as identifiers and the variabls hold the values assignes to them. Generally a variable cannot hold more than one value at the same time.
In python programming language, we need not to specify the data type of the variable with it as python is a type infer and smart enough language that itself get the data type of the variable on tha basis of the value assigneed to the variable.
We can name a variable as we want such as a group of letters or alphabets and/of groups of letters and digits but, it should always be kept in mind that the name of variable should always start with the letter or underscore.
It should also be kept in mind that the uppercase and the lowercase letter represent diffrenet varialbes i.e. 'A' and 'a' represent two different variables.
A variable is an example of an identifier. An identifier is used to identify the literals that are used in the program. The rules that are used to name an identifier are as follows:
Declaring Variable and Assigning Values >>>a=10 >>>print(a) 10
If we are using python programming language then there is no need to declare the variable before using that in the application. We can create the variables at the time when required.
In the programming laguage python we do not need to declare the variables explicitely i.e. when we assign any value to to any variable then that variable is automatically declared.
The equal (=) operator is used to assign value to a variable.
Multiple Assignment >>>a=b=c=500 >>>print(a,b,c) 500 500 500
In python , we can assign the values to multiple variables withion a single statement and this is known as multiple assignment. So, there is no need to distictily assign the values to different variables.
Multiple assignment in python can be done in two ways, first is that multiple variables can be assignes a single value and the second way is to assign multiple values to multiple variables. Let's see the following example:
1. Assigning single value to multiple variables:
500 500 500
2.Assigning multiple values to multiple variables:
>>>a,b,c=100,200,300 >>>print(a,b,c) 100 200 300
100 200 300