Python Data Types - Overview

The python language supports vast number of data Operations. To learn all these important and dynamic range of features we must learn all of its inbuilt data types.

There are some major types of data we know numeric, text, sequential, sets, etc.

To handle all these different types of data we have different data types specified in python.

1.    For Numeric type of data, we have

a.    int

b.    float

c.     complex

2.   For text type of data, we have

a.    str

3.   For sequences we have

a.    list

b.    tuple

c.     range

4.   For data where mapping is required, we have

a.    dict

5.   For Set types, we have

a.    set and

b.    frozenset

6.   For Boolean values, we have

a.    bool

7.   For binary data, we have

a.    bytes 

b.    bytearray

c.     memoryview

8.   If one wanted to store null value for that too, we have

a.    NoneType

To initialize any a variable in python with any data type we just have to pass value with that data type like e.g., to store integer:  v = 65. So, this will store value 65 of type int.

Similarly, for strings: v = ‘Python’ or v = “python”.

Same can be done for other data types as well.

In python, we can reinitialize a variable with another value which can of different data type as well.


To check data type of any variable we can use type(v) built-in function.

e.g.,

kilos = 54

Data type of kilos can be checked like type(kilos)

This will return: <class 'int'> as output as value 54 is of int data type.

 

To check the memory address of any value we can use id(var).

a=10

id(a) will return address of memory location where 10 value is stored.


Thanks!!!

Hope you got some idea of data types.


    

Comments

Popular posts from this blog

Python Data Types - float

Python Data Types - Complex

Python Data Types - int