0% found this document useful (0 votes)
8 views2 pages

Class 3

Uploaded by

Deva Monish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views2 pages

Class 3

Uploaded by

Deva Monish
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

All fundamental data types are immutable,

• Cannot change the content once we create an object


• a = 55
• If we are trying to change its content new object will be created

COLLECTION RELATED DATA TYPES:

6. List:

*mutable

* mentioned inside [] --- square bracket

* l = [10, 21.4, True, ‘pyth’]

* list is heterogeneous in nature

* order is preserved

* duplicates are allowed. list = [10, 45, 34, 10, 10, True, ’god’]

* growable in nature list.append(), list.remove()

* indexing, slicing allowed

7.Tuple:

* all properties are same as list but tuple is immutable

* tuple is mentioned in ()

* we cannot change its content(add,remove)

* indexing, slicing allowed

8. Set data type:

• Mentioned in {}
• Duplicates not allowed
• Order is not preserved
• Indexing, slicing not available (since no order)
• Mutable
• s = {1,2,4,’moon’}
s.add(50)
s.remove(3)

* [] - list, () - tuple , {} – dict not set

9.Frozen set data type:

* immutable

* other things are same as set


s = {1,67,34, ‘look’}

fs = frozenset(s)

print(fs)

10. dict data type:

* {}

* key – value pairs

* d = {1 : ‘dog’, 2 : ‘cat’, 3 : ‘rat’}

* growable in nature

* d = {}

* d[1] = ‘dog’

e.g code:

d = {}

d[1] = 'dog'

d[2] = 23

d[3] = True

print(d)

• order is not preserved


• indexing and slicing not allowed since order is not there
• order may be seen for few elements but for large no of data there will be no order
• so in dict data type order is not there
• duplicate keys not allowed, if duplicate key is given old value will be replaced with new value
• duplicate values allowed

You might also like