Datatype | Description | Is Immutable? | Example |
Int | We can use to | Immutable | >>> a=10 >>> type(a) <class ‘int’> |
Float | We can use to | Immutable | >> b=10.5 >>> type(b) <class ‘float’> |
Complex | We can use to | Immutable | >> c=10+5j >> type(c) <class ‘complex’> >>> c.real 10.0 >>> c.imag 5.0 |
Bool | We can use to | Immutable | >> flag=True >> flag=False >> type(flag) <class ‘bool’> |
Str | To represent | Immutable | >> s=’durga’ >> type(s) <class ‘str’> >>> s=”durga” >> s=”’Durga Software Solutions… Ameerpet”’ >>> type(s) <class ‘str’> |
bytes | To represent a | Immutable | >> list=[1,2,3,4] >> b=bytes(list) >> type(b) <class ‘bytes’> |
bytearray | To represent a | Mutable | >> list=[10,20,30] >> ba=bytearray(list) >>> type(ba) <class ‘bytearray’> |
range | To represent a range | Immutable | >>> r=range(10) |
list | To represent an | Mutable | >> l=[10,11,12,13,14,15] >>> type(l) <class ‘list’> |
tuple | To represent an | Immutable | >> t=(1,2,3,4,5) >> type(t) <class ‘tuple’> |
set | To represent an | Mutable | >> s={1,2,3,4,5,6} >> type(s) <class ‘set’> |
frozenset | To represent an | Immutable | >> s={11,2,3,’Durga’,100,’Ramu’} >>> fs=frozenset(s) >> type(fs) <class ‘frozenset’> |
dict | To represent a group | Mutable | >> d = {101:’durga’, 102:’ramu’, 103:’hari’} >> type(d) <class ‘dict’> |