Data Types in Python :
Data type is the type of data / value a variable can hold. Python supports several built-in data types. Data types are very much essential for writing correct and efficient python code.
Data Type represent the type of data present inside a variable.
In Python, we are not required to specify the type of the variable explicitly. Based on value provided, the type is assigned
automatically. Hence Python is Dynamically Typed Language.
In other words, Dynamically Typed Language means 'type' concept is availbale, but we are not require to declare explicitly rather it is automatically assigned.
There are following built-in data types
1) Numeric
2) Sequence
3) Dictionary
4) Set
5) Boolean
Before going to discuss about these data types, let us know few imporatant points now.
- In Python, every thing is an Object.
Let's take an example :
a = 10
Here 'a' is the reference variable of object 'int' having value 10. Or 'a' is an object of <class 'int' (integer)> having value 10.
- The frequently used built-in functions are
type() : It is to check the type of variable.
id() : It is used to get address of object.
print() : It is used to print the value.
Example :
a = 10
print(type(a))
print(id(a))
Output :
<class 'int'>
10758024
Comments
Post a Comment