Answer to Question #285040 in Python for Vivek

Question #285040


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.


1
Expert's answer
2022-01-05T16:24:53-0500
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}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS