Www.profajaypashankar.com



#A) write a python script to sort(ascending and descending )a dictionary by value.released={'python 3.6':2017,'pythohn 1.0':2001,'python 2.3':2010}print('original dictionary:',released)print('dictionaryin ascending order by value :')for key , value in sorted (released.items()): print(key,value)print('dictionaryin descending order by value :')for key , value in sorted (released.items(),reverse=True): print(key,value)#B)Write a Python script to concatenate following dictionaries to creat a new one.dic1={1:10,2:20}dic2={3:30,4:40}dic3={5:50,6:60}dic4={}for d in(dic1,dic2,dic3):dic4.update(d)print(dic4)#C)Write a Python Program to sum all the items in a dictionary.my_dict={'data1':100,'data2':-54,'data3':247}print(sum(my_dict.values())) ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download