set category : 1. A collection of unique elements(no duplicates) is called a set 2. set in python is supported by -- set datatype -- frozenset datatype set datatype : 1. It is created explictily by using {} (flower/curly braces) 2. It contain unique elements and cannot contain mutable objects(list,set) 3. It do not support indexing 4. The elements are not arranged linearly 5. we can create a set from the existing object using set() 6. A set object is mutable(updatable,growable,shrinkable) st = {47,"hello",None,True,56.21,6-8j,47,True} print(st) #{True, 56.21, None, (6-8j), 47, 'hello'} #A set do not allow duplicates st[2] #TypeError: 'set' object is not subscriptable(no index support) print(st) st.update([59]) print(st) {True, 56.21, None, (6-8j), 47, 'hello'} {True, 56.21, None, (6-8j), 47, 'hello', 59} st = {47,"hello",[None,True,56.21],6-8j,(47,True),{12,False}} #TypeError: unhashable type: 'list' st = {47,"hello",6-8j,(47,True),{12,False}} #TypeError: unhashable type: 'set' lst = [47,"hello",None,True,56.21,6-8j,47,True] print(lst) type(lst) st_lst = set(lst) print(st_lst) type(st_lst) {True, 56.21, None, (6-8j), 47, 'hello'} #set frozenset datatype : 1. It is similar to a set datatype but is immutable 2. we cannot create frozenset explicitly but we can convert the existing collection into a frozenset using frozenset() lst = [47,"hello",None,True,56.21,6-8j,47,True] print(lst) type(lst) fst_lst = frozenset(lst) print(fst_lst) type(fst_lst) frozenset({True, 56.21, None, (6-8j), 47, 'hello'}) frozenset fst_lst.update([54]) #AttributeError: 'frozenset' object has no attribute 'update' Map Category : 1. The category that support a key-value pair similar to a language dictionary(A Word with one or more meanings) 2. The datatype that support Map category is dict datatype 3. The dict datatype object can be created in the following form Syntax: dict_name = { key1 : values1, key2 : values2, key3 : values3, : : : : keyn : valuesn } Example: dct_stu = { 'rno' : 1015, 'name':'Abhi', 'address':'Vizag' } print(dct_stu) #{'rno': 1015, 'name': 'Abhi', 'address': 'Vizag'} 4. The keys and values can be of any type. 5. The key can be one and the values associated with the key can be one to many dct_stu = { 'rno' : {1015,1016,1017}, 'name': ['Abhi','Vijay','Harsh'], 'address':('Vizag','Vizag','Hyderabad') } print(dct_stu) {'rno': {1016, 1017, 1015}, 'name': ['Abhi', 'Vijay', 'Harsh'], 'address': ('Vizag', 'Vizag', 'Hyderabad')} dct_stu = { ['rno1,rno2,rno3'] : {1015,1016,1017}, 'name': ['Abhi','Vijay','Harsh'], 'address':('Vizag','Vizag','Hyderabad') } print(dct_stu) #TypeError: unhashable type: 'list' 6. Keys can't be duplicated ,it may not give error , but the latest key's value is given in the dictionary dct_stu = { 'rno' : 1015, 'name':'Abhi', 'address':'Vizag', 'rno' : 1016, } print(dct_stu) #{'rno': 1016, 'name': 'Abhi', 'address': 'Vizag'} 7. Values can be duplicated dct_stu = { 'rno' : 96, 'name':'Abhi', 'address':'Vizag', 'marks' : 96, } print(dct_stu) #{'rno': 96, 'name': 'Abhi', 'address': 'Vizag', 'marks': 96} 8. We do not index like a sequential collection, but the key acts as the index dct_stu[0] #KeyError: 0 #Keys are the indices print(dct_stu['rno']) #96