## Manage students and their assignments using PYTHON!!!!! s_dict = [{'id' : 101, 'first_name' : 'Alice', 'last_name' : 'Anderson', 'assignments' : [('assignment_1' , 4),('assignment_2' ,...


## Manage students and their assignments using PYTHON!!!!!

s_dict = [{'id' : 101, 'first_name' : 'Alice', 'last_name' : 'Anderson', 'assignments' : [('assignment_1' , 4),('assignment_2' , 2),('assignment_3', 4)]},            {'id': 102, 'first_name' : 'Brian', 'last_name' : 'Boru', 'assignments' : [('assignment_1' , 3),('assignment_2' , 1),('assignment_3', 0)]},            {'id': 103, 'first_name' : 'Chester', 'last_name' :'Copperpot', 'assignments' : [('assignment_1' ,2),('assignment_2' , 4), ('assignment_3', 4)]},            {'id': 104, 'first_name' : 'Diana', 'last_name' : 'Dinkins', 'assignments' : [('assignment_1' , 1),('assignment_2' , 3),('assignment_3', 3)]},            {'id': 105, 'first_name' : 'Edgar', 'last_name' : 'Powong', 'assignments' : [('assignment_1' , 4),('assignment_2' , 4),('assignment_3', 3)]},            {'id': 106, 'first_name' : 'Francine', 'last_name' : 'Franken', 'assignments' : [('assignment_1' , 3),('assignment_2' , 3),('assignment_3', 2)]},            {'id': 107, 'first_name' : 'Gary', 'last_name' : 'Golden', 'assignments' : [('assignment_1' , 0),('assignment_2' , 2),('assignment_3', 1)]},            {'id': 108, 'first_name' : 'Henra', 'last_name' : 'Hector', 'assignments' : [('assignment_1' , 2),('assignment_2' , 4),('assignment_3', 4)]},            {'id': 109, 'first_name' : 'Indica', 'last_name' : 'Indiana', 'assignments' : [('assignment_1' , 2),('assignment_2' , 1),('assignment_3', 0)]},            {'id': 110, 'first_name' : 'Jack', 'last_name' : 'John', 'assignments' : [('assignment_1' , 4),('assignment_2' , 3), ('assignment_3', 4)]}]  # Inspect data set and object class print(type(s_dict))  #################################  #1.  COMPLETED   #2.  Create a function that returns a list of the n student dictionaries with the highest grades (0-4) on the assignment passed in.  For the parameters, #### it will accept the student dictionaries (see s_dict above), a string representing an assignment name (i.e. assignment_1) and a number n that #### represents the number of high scores to return from s_dict.  If there is a tie, then it is broken by returning the student(s) with the lowest 'id' numbers. #### Function name: highest_n_grades(students, assignment_name, n) #### Function will return a LIST.    # Code I tried to use but doesn't work................... def highest_n_grades(students, assignment_name, n):     """ returns n number of students with highest grades - for ties, it returns lowest ID number"""     sort_orders = sorted(students, key = lambda i : x[assignment_name], reverse = True)     n = 0     for i in students:         for a in i['assignments']:             assignment_name = a[0]             assignment_score = a[1]             n = n + 1             if n < len(sort_orders):="" return="" return(highest_n)="" print(highest_n_grades(s_dict,="" 'assignment_2',="" 4)="" #3.="" create="" a="" function="" that="" adds="" grades="" to="" a="" student="" record.="" for="" the="" parameters,="" it="" will="" accept="" one="" student="" dictionary,="" a="" string="" representing="" an="" assignment="" name,="" ####="" and="" a="" grade.="" if="" the="" assignment="" name="" does="" not="" exist="" in="" the="" student's="" list="" of="" assignments,="" then="" the="" assignment="" and="" grade="" will="" be="" added="" to="" the="" end="" of="" the="" list="" ####="" of="" assignments.="" if="" this="" operation="" is="" successful="" then="" the="" function="" will="" return="" true="" otherwise="" it="" will="" return="" false.="" ####="" function="" name:="" add_grade(student,="" assignment_name,="" grade)="" ####="" function="" will="" return="" a="" boolean="" #="" code="" i="" tried="" to="" use="" but="" doesn't="" work...................="" def="" add_grade(student,="" assignment_name,="" grade):="" """adds="" a="" grade="" to="" a="" student="" record"""="" for="" i="" in="" student:="" for="" a="" in="" i['id']:="" student="a[0]" for="" assign="" in="" i['assignments']:="" assignment_name="assign[0]" grade="assign[1]" if="" assignment_name="" not="" in="" assign:="" student['assignments'].append()="" else:="" return="" false="" print(str(add_grade(101,="" 'assignment_3',="" 3)))="" #4.="" create="" a="" function="" that="" updates="" student="" grades.="" for="" parameters,="" it="" will="" accept="" a="" student="" dictionary,="" a="" string="" representing="" an="" assignment="" name="" and="" a="" grade.="" ####="" if="" that="" assignment="" name="" exists,="" then="" the="" grade="" should="" be="" changed="" to="" the="" supplied="" grade.="" if="" the="" assignment="" was="" found="" and="" updated,="" then="" the="" function="" should="" ####="" return="" true="" otherwise="" it="" should="" return="" false.="" the="" order="" of="" assignments="" should="" be="" preserved.="" ####="" function="" name:="" update_grade(student,="" assignment_name,="" grade)="" ####="" function="" will="" return="" a="" boolean="" def="" update_grade(student,="" assignment_name,="" grade):="" #5.="" create="" a="" function="" that="" returns="" a="" list="" of="" students="" ids="" for="" students="" who="" have="" an="" average="" on="" all="" assignments="" that="" is="">= 2.0.  For parameters, it will accept the ## student dictionaries.  It should return a list of student IDs which represent students having an average grade on ALL their assignments which is >= 2.0. ## Function name: passing_student_ids(students) ## Function will return a LIST  def passing_student_ids(students):     passing_grades_ids = []     sum_grade = 0     count_grade = 0     for a in students:         for t in a['assignments']:             sum_grade = sum_grade + a[1]              count_grade = count_grade + 1             average = sum_grade / count_grade             if average >= 2.0:                 passing_grades_ids.append('id')     return passing_grades_ids print(passing_student_ids(s_dict))
Oct 13, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here