- Data types are nothing but some of the keywords of the programming language, which are used to specify what type of data has to be store into the variables.
- Without data types we cannot store the data into the variables.
- Python supports the dynamic data type i.e. at the time of execution of program data type of the variable will be decided based on the data which is assigned to that variable.
- At the time of writing the program, programmers should not specify data type to the variables explicitly. Otherwise we will get an error.
- Python data type are categorized into two types - Fundamental and Collections datatypes.
Fundamental datatypes
The variables which are represented with fundamental data types stores the address of the object in which we can represent only one element.
int, long, float, complex, bool, str
Program - Python supports so many builtin functions.
type() - This function is used to know the datatype of the variables.
id() - This function is used to know the address of the object which is pointed by the variables.
print() - This function is used to display the data on the console
Example -
i=12345
print i
print type(i)
print id(i)
j=123456789012345
print j
print type(j)
print id(j)
k=123.123
print k
print type(k)
print id(k)
x=3+4j
print type(x)
print id(x)
y=True
print y
print type(y)
print id(y)
Output -
12345
<type 'int'>
44530772
123456789012345
<type 'long'>
45326680
123.123
<type 'float'>
44168144
<type 'complex'>
45302080
True
<type 'bool'>
1679307860
No comments:
Post a Comment