Click here to Skip to main content
14,732,615 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
1. Suppose a dictionary contains the marks of each student where key is the 
student name and value is the mark. Your task is to print the name of the 
pair of students whose average mark is equal or greater than 90. For 
example, a dict contains the following elements

        My_dict = {‘A’:87,’B’:93,’C’:’90,’D’:84,’E’:89}
        Pair of students having 90 or more marks as average are - AB, BC, BE.
        BA, CB and EB should not be printed as the pairs are printed once.

𝐒𝐚𝐦𝐩𝐥𝐞 𝐈𝐧𝐩𝐮𝐭:
𝐒𝐚𝐦𝐩𝐥𝐞 𝐎𝐮𝐭𝐩𝐮𝐭:

What I have tried:

im tryinhg my best but could solve this please help sort this or else i wont get marks...........................................................
Updated 25-Sep-20 5:22am
Sandeep Mewara 25-Sep-20 8:27am
You need to attempt and share your effort. For now, seems like just a homework question.

Make a list of dictionary keys (see, for instance: How to return dictionary keys as a list in Python? - Stack Overflow[^]) then make an outer loop iterating on items i=0..KEYS-2 and a inner loop iterating on items j=(i+1)..KEYS-1. Every time
you have found a good pair.
im tryinhg my best but could solve this please help sort this or else i wont get marks

You want us to do your homework so that you can get marks. In other words, we do the job for free and you graduate, not really fair trade.
Can someone solve this for me

In this site, we help you to fix your code, but you need to have done something, and show it with explanation of problem.
I solved it just to get an idea of its difficulty. I am not a Python expert (like the great CPallini), so I needed to look at some of the documentation. I used the following reference pages to help me:
5. Data Structures — Python 3.7.9 documentation[^]
Built-in Types — Python 3.7.9 documentation[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900