- Variables are nothing but reserved memory locations to store values. It means that when you create a variable, you reserve some space in the memory.
- Based on the data type of a variable, the interpreter allocates memory and decides what can be stored in the reserved memory.
There are different types of data types in python:
Note: I will discuss these all in separate section
A variable can hold different types of values.
for example if you assign a string to a variable then that variable belong to string data types,and if you assign number to the same variable the its belong to number data types.
Means to say that you can store any type of variable in any variable,that variable behaves according to that particular data type. need not to declare data type before the variable name (as done in language like C and C++).
- For declaration of variable in python no need to declare data type of it.
Syntax : variable_name = assigned_value
You may assign values to more than one variable at a time.
example : a=b=c=2 means a=2,b=2,c=2.
- Variable name not start with a number (show syntax error) but you can use number inside the variable name.
=>> This is all about variable as we continue we know more about variables as we go deeper in it.