# Summary of Datatypes in Python 3

### Example

Int

We can use to
represent the
whole/integral
numbers

Immutable

>>> a=10

>>> type(a)

<class ‘int’>

Float

We can use to
represent the
decimal/floating
point numbers

Immutable

>> b=10.5

>>> type(b)

<class ‘float’>

Complex

We can use to
represent the
complex numbers

Immutable

>> c=10+5j

>> type(c)

<class ‘complex’>

>>> c.real 10.0

>>> c.imag 5.0

Bool

We can use to
represent the logical
values (Only allowed
values are True and
False)

Immutable

>> flag=True

>> flag=False

>> type(flag)

<class ‘bool’>

Str

To represent
sequence of
Characters

Immutable

>> s=’durga’

>> type(s)

<class ‘str’> >>> s=”durga”

>> s=”’Durga Software Solutions… Ameerpet”’

>>> type(s) <class ‘str’>

bytes

To represent a
sequence of byte
values from 0-255

Immutable

>> list=[1,2,3,4]

>> b=bytes(list)

>> type(b)

<class ‘bytes’>

bytearray

To represent a
sequence of byte
values from 0-255

Mutable

>> list=[10,20,30]

>> ba=bytearray(list) >>> type(ba)

<class ‘bytearray’>

range

To represent a range
of values

Immutable

>>> r=range(10)
>>> r1=range(0,10)
>>> r2=range(0,10,2)

list

To represent an
ordered collection of
objects

Mutable

>> l=[10,11,12,13,14,15] >>> type(l)

<class ‘list’>

tuple

To represent an
ordered collections of
objects

Immutable

>> t=(1,2,3,4,5)

>> type(t)

<class ‘tuple’>

set

To represent an
unordered collection
of unique objects

Mutable

>> s={1,2,3,4,5,6}

>> type(s)

<class ‘set’>

frozenset

To represent an
unordered collection
of unique objects

Immutable

>> s={11,2,3,’Durga’,100,’Ramu’} >>> fs=frozenset(s)

>> type(fs)

<class ‘frozenset’>

dict

To represent a group
of key value pairs

Mutable

>> d = {101:’durga’, 102:’ramu’, 103:’hari’}

>> type(d)

<class ‘dict’>