Answer to Question #193516 in Python for Manisha Sharma

Question #193516

Given list of students’ records. Write a program with signature as below: Method Name: getStudentsWithMarksMoreThan() Input: marks – Integer Output: List of Students having marks more than input Also add Unit Test case – both positive and negative. You can do in choice of your language (Any high level language like – Java, Python, PHP, C#, JavaScript) For example JSON given below of 3 students for your reference.


1
Expert's answer
2021-05-14T18:21:07-0400
"""
Dictionary is the basic structure in Python
It is logical to take student data records as a dictionary where the dictionary
key is the student's name and the value is an integer list 
(the number of points for various subjects)
"""
def getStudentsWithMarksMoreThan(arg_dict, mark):
    result = []
    for key in arg_dict:
        if all([item > mark  for item in arg_dict[key]]):
            result.append(key)
    return result


# correct example 
students = {}
students['Boo']= [1,2,3,2]
students['Foo'] = [3,4,3,3]
students['Goo'] = [4,4,4,4]
# Display of names of students with all scores greater than 2
# output :Foo, Goo
print (* getStudentsWithMarksMoreThan(students, 2),sep=', ')

# Incorrect test - the user enters characters instead of integer values
# for the purpose of deception

students_bag = {}
students_bag['Aoo']= ['6','8','7']
students_bag['Doo']= ['60','80','70']
students_bag['Coo']= ['10','20','30']
# output result Aoo, Doo ;evaluation criterion more than 50
# Doo mistakenly listed
print (* getStudentsWithMarksMoreThan(students_bag, '50'),sep=', ')

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