Recall the Scores dataset. Each student-entry in it is represented as a dictionary, for example:
{'SeqNo': 0, 'Name': 'Devika', 'Gender': 'F', 'City': 'Bengaluru',
'Mathematics': 85, 'Physics': 100, 'Chemistry': 79}
All keys of the dictionary are strings. For SeqNo and the subjects, the corresponding values are integers. The values corresponding to Name, Gender and City are strings. The entire dataset is a list of such dictionaries named scores_dataset.
Write a function named get_marks that accepts scores_dataset and a variable named subject as arguments. It should return the marks scored by all students in subject as a list of tuples. Each element of this list is of the form (Name, Marks). Append the tuples in the order in which the students appear in the dataset.
You do not have to accept input from the user or print anything. You just have to write the definition of the function.
Example
get_marks([{'Name': 'Devika', 'Physics': 100}, {'Name': 'Karthik', 'Physics': 72}], 'Physics')
-> [('Devika', 100), ('Karthik', 72)]
Implement this function:
def get_marks(scores_dataset, subject):
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: scores_dataset, subject.
Input
[{'SeqNo': 0, 'Name': 'Devika', 'Gender': 'F', 'City': 'Bengaluru', 'Mathematics': 85, 'Physics': 100, 'Chemistry': 79}, {'SeqNo': 1, 'Name': 'Karthik', 'Gender': 'M', 'City': 'Chennai', 'Mathematics': 60, 'Physics': 72, 'Chemistry': 91}, {'SeqNo': 2, 'Name': 'Lalit', 'Gender': 'M', 'City': 'Kanpur', 'Mathematics': 45, 'Physics': 58, 'Chemistry': 66}]
'Physics'
Output
[('Devika', 100), ('Karthik', 72), ('Lalit', 58)]