9. Python all data types compares

 

Python all data types compares.

Data Types

Description

Is it immutable

order is there

indexing/slicing

duplicates

int

To represent whole numbers (a=10)

immutable

 NA

 NA

 NA

float

To represent floating-point value (a=10.5)

immutable

 NA

 NA

 NA

complex

To represent complex numbers (a=1+2j)

immutable

 NA

 NA

 NA

bool

To represent logical values a=True, b=Flase

immutable

 NA

 NA

 NA

str

 To represent a sequence of charters s = 'sdf'

immutable

 NA

Yes

 NA

list

An ordered collection of objects l = [10,20,30,40]

mutable

yes

yes

yes

tuple

The read-only version of list  l = (10,20,30,40)

immutable

yes

yes

yes

set

An unordered collection of unique objects s = {10,20,30,40}

mutable

No

NO

NO

frozenset

The read-only version of set  fs = frozenset(s)

immutable

No

NO

NO

dict

To  represent key-value pairs d = {100:surya, 200: ravi}

mutable

 Yes

NO

Key: No/Value: Yes

bytes

A group of byte values  range (0-255)

immutable

yes

yes

yes

bytearray

A group of byte array values  range (0-255)

mutable

yes

yes

yes

range

To represent a sequence of values  r = (1-20)

immutable

yes

yes

No

long

Not in python

char

Not in python

0 Comments

Post a Comment

Post a Comment (0)

Previous Post Next Post