Write a program that keeps student's name and his marks in a dictionary as key-value pairs. The
program should store records of 10 students and display students name and marks of five
students in decreasing order of marks obtained.
import itertools
def stevo_dic(list1, list2):
l_2 = round(len(list1)/2)
dic = {}
for i in range(len(list1)):
dic[list1[i]] = list2[i]
return dict(itertools.islice(dic.items(), l_2))
stevo_dic(['David', 'Samuel', 'Stevo', 'Brainy', 'Frank', 'Daniel', 'Paul', 'Peter', 'Taiwo', 'Kenny'], [90, 98, 21, 87, 65, 90, 34, 76, 91, 46])
{'David': 90, 'Samuel': 98, 'Stevo': 21, 'Brainy': 87, 'Frank': 65}
Comments
Leave a comment