Fill This Form To Receive Instant Help

Help in Homework
trustpilot ratings
google ratings


Homework answers / question archive / You have a list of strings which contain student record

You have a list of strings which contain student record

Computer Science

You have a list of strings which contain student record. Each string contains the student's name, and their grades in Maths, Physics and Chemistry. The grades can be floating values. These values (names and grades) are separated by comma. You are required to save the record in a dictionary data type. The user then enters a student's name. Output the average percentage marks obtained by that student, correct to two decimal places. Example: input : grades = ["Jake, 99, 70, 50", "Dennis, 100, 100, 98"] name = "Dennis" output: "The average grade of Dennis is 99.33" In [58]: grades = ["Jake ,99 , 70, 55", "Dennis, 100, 100, 98"] det_grades = {} student_list = [i. strip("") . split(", ") for i in grades] for student in student_list: names = student[0] total = int(student[1] ) + int(student[2]) + int(student[3]) avg_grade = total/3 dct_grades [ names ] = round (average, 2) name = 'Jake' print ( 'The average grade of '+name+ ' is', dot_grades [name]) IndexError Traceback (most recent call last) <ipython- input-58-668cb700ed31> in <module> 7 for student in student_list: 8 names = student[0] - --->9 total = int(student[1]) + int(student[2]) + int(student[3]) 10 avg_grade = total/3 11 dct_grades [ names ] = round (average, 2) IndexError: list index out of range

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE