Python Variables and Types
Variables are the containers which can hold some value. 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.
Python is dynamically Typed Language that means In Python, we don't need to specify the type of variable because Python is a type infer language and smart enough to get variable type.
Variable names can be a group of both letters and digits, but they have to begin with a letter or an underscore.
Declaring and Assigning Values to Variables
In Python we don't need to provide the type of variable , Python is smart enough to know the type at run time .
We don't need to declare explicitly variable in Python. When we assign any value to the variable that variable is declared automatically.
The equal (=) operator is used to assign value to a variable.
name='durgesh' #string type variable
number=568 #integer type variable
salary =566556.775 # float type variable
Python allows you to assign a single value to several variables simultaneously. For example â??
a = b = c = 1
# assigning the single value to multiple variable
Example : Assigning multiple values to multiple variables:
# assigning the multiple values to multiple variable
how to find the type of variable at run time
type(variable) - function is used to find the type of variable at Run time.
#Program to print the type of any varible at run time
#type of n
#type of v
#type of f
#type of c
< class 'int' >
< class 'str' >
< class 'float' >
< class 'complex' >
What next ?
Python Lines and Indentation