Write a program to get the maximum and minimum value of dictionary


This program is written in Python and calculates the maximum and minimum values in a dictionary called "marks". The "marks" dictionary has five key-value pairs, each representing a subject and its corresponding marks obtained by a student. The keys are "m1", "m2", "m3", "m4", and "m5", and their respective values are 78, 89, 64, 35, and 71.

In the program, the "values()" method of the dictionary is used to extract all the values of the dictionary and store it in a variable called "v". Next, the "max()" and "min()" functions are used to find the maximum and minimum values in the list "v", respectively. The results are stored in the variables "maxi" and "mini". Finally, the program prints the maximum and minimum values using the "print()" function.

Source Code

marks={"m1":78 , "m2":89 , "m3":64 , "m4":35 , "m5":71}
 
v = marks.values()
maxi = max(v)
mini = min(v)
 
print("Maximum :",maxi)
print("Minimum :",mini)

Output

Maximum : 89
Minimum : 35