14,733,323 members
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.

𝐒𝐚𝐦𝐩𝐥𝐞 𝐈𝐧𝐩𝐮𝐭:
{‘A’:87,’B’:93,’C’:’90,’D’:84,’E’:89}
𝐒𝐚𝐦𝐩𝐥𝐞 𝐎𝐮𝐭𝐩𝐮𝐭:
AB
BC
BE

What I have tried:

im tryinhg my best but could solve this please help sort this or else i wont get marks...........................................................
Posted
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.

## Solution 4

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[^]

## Solution 2

Quote:
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.
Quote:
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.

## Solution 1

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
dict[list[i]]+dict[list[j]]>=180
you have found a good pair.