Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I can get this far (below), but all I have now is two lists with the names and the grades. I know im approaching this

image text in transcribed

I can get this far (below), but all I have now is two lists with the names and the grades. I know im approaching this wrong, which way should I approach? Cheers (python)image text in transcribed

Write a function called create_grade_dictionary (students) that takes a list of student-tuples as a parameter and returns a dictionary that maps from grade to a list of students who obtained that grade. The student list in each grade-item in the dictionary should be sorted in ascending order (smallest to largest/A-Z) For example: Test Result students = [('Angus', 'A+'), ('Peter', 'C+'), ('Fred', 'C+'), ('Mary','A'), ('Liu','C+')] A ['Mary'] grades = create_grade_dictionary (students) A+ ['Angus'] for k in sorted(grades): C+ ['Fred', 'Liu', 'Peter'] print(k, grades[k]) L wewew.py - C:/Users/willi/AppData/Local/Programs/Python/Python37-32/wewew.py (3.7.4) File Edit Format Run Options Window Help def create grade dictionary (students): dict1 = {} grades = [] names = [] for ele in students: names.append(ele[0]). if ele[1] not in grades: grades.append(ele[1]) students = [('Angus', 'A+'), ('Peter', 'C+'), ('Fred', 'C+'), ('Mary', 'A'), ('Liu', 'C+')] grades = create grade dictionary (students), for k in sorted (grades): print(k, grades[k])

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Processing

Authors: David Kroenke

11th Edition

0132302675, 9780132302678

More Books

Students also viewed these Databases questions