-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtask 1.4.py
25 lines (25 loc) · 871 Bytes
/
task 1.4.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
'''4. Get the key corresponding to the minimum value from the following dictionary using appropriate python logic.
sample={
‘physics’, 88 , ‘maths’, 75, ’chemistry’ , 72,’Basic electrical’ , 89
}
'''
print('enter the number of key value pairs you want to enter')
#taking input of the number of key value pairs
n=int(input())
print('enter the key value pairs as follows')
print('key<space>value')
#declaring an empty deictionary
dic={}
#running a loop n times for n inputs
for i in range(n):
#taking input of key value pairs seperated by space
a,b=input().split()
#adddding it to the dictionary
dic[a]=int(b)
#converting the dictionary of a list of the key value pairs
k=list(dic.items())
#sorting the dictionary based on the values
k.sort(key=lambda x: x[1])
#printing the key representing the lowest value
print("the lowest key is")
print(k[0][0])