Assignment#5 : Mohammed Abdul Wasay
Given Input: sample_dict = { 'Physics': 82, 'Math': 65, 'history': 75 }
Expected output: Math
sample_dict = {'Physics': 82,'Math': 65,'history': 75}
# print(sample_dict.get('Math'))
print(min(sample_dict, key=sample_dict.get))
Math
Given Input: sample_dict = {'a': 100, 'b': 200, 'c': 300}
Expected output: 200 present in a dict
# program to check if value exists in dictionary
def checkif_value_exist(dict1, value):
Is_exist = False
for key, val in dict1.items():
if val == value:
Is_exist = True
print(value, "is present in dictionary")
return Is_exist
sample_dict = {'a': 100, 'b': 200, 'c': 300}
value = 200
checkif_value_exist(sample_dict,value)
200 is present in dictionary
True
Given Input: dict1 = {'Ten': 10, 'Twenty': 20, 'Thirty': 30} dict2 = {'Thirty': 30, 'Fourty': 40, 'Fifty': 50}
Expected output: {'Ten': 10, 'Twenty': 20, 'Thirty': 30, 'Fourty': 40, 'Fifty': 50}
# program to merge two dictionaries while removing any repeated item
def DictListMerge( dict1, dict2):
dict1.update(dict2)
print(dict1)
dict1 = {'Ten': 10, 'Twenty': 20, 'Thirty': 30}
dict2 = {'Thirty': 30, 'Fourty': 40, 'Fifty': 50}
DictListMerge( dict1, dict2)
{'Ten': 10, 'Twenty': 20, 'Thirty': 30, 'Fourty': 40, 'Fifty': 50}