Question: Please note that the 3 apostrophes beside the first student name Jade and the last student score of 100 are required for the test case

Please note that the 3 apostrophes beside the first student name Jade and the last student score of 100 are required for the test case to pass.

sample code that works but does not print the 3 apostrophes

Please note that the 3 apostrophes beside the first student name Jade

Write a python function max_scores(grades) that takes in a gradebook of students and returns a stripped multiline string where each line is in the form student_name: max_score. A gradebook is a multiline string where each line contains the students name followed by their scores, separated by commas.

Hint #1: You may want to use .split() and .splitlines(). Hint #2: Remember that the scores are strings you need to convert them to integers first. Hint #3: Make sure to use the .strip() method at the end to get rid of trailing spaces.

Test

grades = '''Jade,50,64,82,14

Brenda,90,67,73,80

Chris,75,75,75,75

John,100,85,90,99'''

assert(max_scores(grades) == '''Jade: 82

Brenda: 90

Chris: 75

John: 100''')

def row_to_list(row): L = row.split(",") for i in range(1, len(L)): if (L[i].isdigit(): L[i] int(L[i]) else: L[i] = 0 return L def csv_str_to_list(grades): grades grades.strip) stu_list = list) for row in gradebook.split(): row_as_list = row_to_list(row) stu_list.append(row_as_list) return stu_list def max_scores(grades): Ist Csv_str_to_list(grades) stu_name for i in range(len(1st)): for j in range(len(lst[i])): stu_name= lst[i][0] max_score = max(lst[i][1:]) print(f"{stu_name}: {max_score}")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!