0% found this document useful (0 votes)
7 views4 pages

PWP Exp9

Uploaded by

surajborgave161
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)
7 views4 pages

PWP Exp9

Uploaded by

surajborgave161
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/ 4

Exp9_st1_05

dictionary = {'MSBTE' : 'Maharashtra State Board of Technical Education',


'CO' : 'Computer Engineering',
'SEM' : 'Sixth'
}
del dictionary['CO'];
for key, values in dictionary.items():
print(key)
dictionary.clear();
for key, values in dictionary.items():
print(key)
del dictionary;
for key, values in dictionary.items():
print(key)

Exp9_st2_05

dictionary1 = {'Google' : 1,
'Facebook' : 2,
'Microsoft' : 3
}
dictionary2 = {'GFG' : 1,
'Microsoft' : 2,
'Youtube' : 3
}
dictionary1.update(dictionary2);
for key, values in dictionary1.items():
print(key, values)
Exp9_st3_05

temp = dict()
temp['key1'] = {'key1' : 44, 'key2' : 566}
temp['key2'] = [1, 2, 3, 4]
for (key, values) in temp.items():
print(values, end = "")

Exp9_st4_05

di = {'a': 100, 'b': 3, 'c': 13, 'd': 69, 'e': 99}


vals = sorted(di.values())
result = {}
for val in vals:
for key, values in di.items():
if val == values:
result[key] = val
print("Ascending order :",result)
result.clear()
vals = sorted(di.values(), reverse=True)
for val in vals:
for key, values in di.items():
if val == values:
result[key] = val
print("Descending order :",result)
Exp9_st5_05

dic1 = {1: 10, 2: 20}


dic2 = {3: 30, 4: 40}
dic3 = {5: 50, 6: 60}
dict4 = {}
for i in (dic1, dic2, dic3):
dict4.update(i)
print("After Concatenating :", dict4)

Exp9_st6_05

d1 = {'a': 100, 'b': 200, 'c': 300}


d2 = {'a': 300, 'b': 200, 'd': 400}
combined1 = {}
combined2 = {}
for key1, values1 in d1.items():
for key2, values2 in d2.items():
if key1 == key2:
combined1[key1] = values1 + values2
else:
combined2[key1] = values1
combined2[key2] = values2
combined2.update(combined1)
print(combined2)
Exp9_st7_05

samp = [{"V":"S001"}, {"V": "S002"}, {"VI": "S001"}, {"VI":"S005"},


{"VII":"S005"},{"V":"S009"}, {"VIII":"S007"}]
li = []
result =[]
val = 0
for i in samp:
for key, value in i.items():
li.append(value)
for i in li:
if li.count(i) < 2:
result.append(i)
print(result)

Exp9_st8_05

di = {'a': 100, 'b': 3, 'c': 13, 'd': 69, 'e': 99}


vals = sorted(di.values(), reverse=True)
result = {}
for val in vals[:3]:
for key, value in di.items():
if val == value:
result[key] = val
print("Highest 3 values in Dictionary :", result)

You might also like