Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

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_2

Step: 3

blur-text-image_3

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

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

1. Identify three approaches to culture.

Answered: 1 week ago

Question

2. Define communication.

Answered: 1 week ago

Question

4. Describe how cultural values influence communication.

Answered: 1 week ago