Question: How do I modify my code to reflect the test results shown below? My code is pasted below #globals name_list = [] score_list = []
How do I modify my code to reflect the test results shown below? My code is pasted below

![shown below? My code is pasted below #globals name_list = [] score_list](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66fa69bb86d1d_09966fa69bb29336.jpg)
![= [] status_list = [] grade_list = [] def is_valid_graded(grade_basis): return grade_basis](https://dsd5zvtm8ll6.cloudfront.net/si.experts.images/questions/2024/09/66fa69bc2da9d_09966fa69bbc5899.jpg)





#globals name_list = [] score_list = [] status_list = [] grade_list = [] def is_valid_graded(grade_basis): return grade_basis == 1 or grade_basis == 0 def is_valid_score(score): #in range 0...100 return score >=0 and score 80: grade = 'A' else: grade = 'B' return grade def compute_passfail(score,grade_basis): if score >= 40: grade = 'Pass' else: grade = 'Fail' return grade def submit(): global name_list, score_list, status_list, grade_list name = input('Enter name?>>') score = int(input('Enter a score?>>')) if not is_valid_score(score): print('Score must be positive') grade_basis = int(input('Enter 1 for graded, 0 for pass/fail >>')) if not is_valid_graded(grade_basis): print('Enter 1 for graded, 0 for pass/fail') return grade = compute_grade(score) grade = compute_passfail(score,grade_basis) name_list.append(name) score_list.append(score) status_list.append(grade_basis) grade_list.append(grade) print(f'Name:{name} Score:{score:.2f}') def compute_average_score(): global score_list total_score = 0.0 num_inputs = 0 for score in score_list: total_score = total_score + score num_inputs = num_inputs + 1 if num_inputs > 0: avg = total_score / num_inputs else: avg = None return avg, num_inputs def summary(): average_score, num_inputs = compute_average_score() if average_score is not None: print(f'Average Score: {average_score:.2f}\tNumber of Inputs {num_inputs:d}') else: print('No Inputs to compute with!') def clear_lists(): global score_list, name_list, status_list, grade_list score_list.clear() name_list.clear() status_list.clear() grade_list.clear() def reset(): clear_lists() def line(): print('-'* 55) def display(): global score_list,name_list,status_list, grade_list if score_list: #strings, and things, when empty, are False. line() print(f'|{"Name":^12s}|{"Score":^12s}|{"Status":^14s}|{"Grade":^12s}|') line() for name,score,status,grade in zip(name_list, score_list, status_list,grade_list): print(f'|{name:12}|{score:12}|{status:14}|{grade:12}|') line() else: print('No Data!') quit = False while not quit: print('1.Submit 2.Summary 3.Reset 4.Display 5.Exit') choice = int(input('Enter choice: ')) if choice == 1: submit() elif choice == 2: summary() elif choice == 3: reset() print('Now ready for new series') elif choice == 4: display() elif choice == 5: clear_lists() quit = True else: print('Invalid Choice!')submit(): prompts the user to enter a name, a score and 1/0 for graded or pass/fail basis. The inputs are read one by one. Name - str score - int graded or not - int Inputs for score and grade status are to be validated. Use two bool functions for validation. (is_valid_score() is_valid_graded() for example) score: check score is in the range 0..100, inclusive of O and 100. Graded or not: check the input is 1 or 0. Write two functions, compute_grade and compute_passfail. For graded inputs, grade is A for score above 80, B for others. For pass/fail inputs, grade is Pass for score at or above 40, Fail otherwise. (you may use Pass and Fail, rather than P or F as values). For each input, make sure only one of the two functions, as appropriate, is called. Submit displays the name, score, status and grade. Scroll to the end to see sample input, output sequence for submit. summary() uses a compute_average_score function. Summary displays: (sample outputs listed at end of this document) 1. Average Score (this is across all inputs), 2. Number of Inputs. If there are no inputs at all, summary() will display: No Data 3. Restriction: do not use built-in list functions for sum, count, or len. Write your own code using loops to find the totals and counts needed. 4. No global variables other than the lists to be used. But if unable to code this way, you may create total and count as global variables, at the cost of 2 points. display() shows the contents of the four (including name) lists. Scroll down to the end of document to see sample output of display. Nicely formatted and presented is important; your presentation of output may vary from what is shown. Restriction: you must use the four lists to generate the display output. Use of alternate structures like a dictionary, not allowed. Submitting five inputs, all on pass fail basis: (you don't need to test so many; this is just for illustration) 1. Submit 2. Summary 3.Reset 4.Display 5.Exit Enter choice: 1 Name >>Martin Score(0..100) >>99 Enter 1 for grade basis, o for pass/fail >>0 Name : Martin Score : 99 Status : PassFail Grade : Pass 1. Submit 2. Summary 3. Reset 4.Display 5.Exit Enter choice: 1 Name >>Mary Score(0..100) >>100 Enter 1 for grade basis, o for pass/fail >> Name : Mary Score : 100 Status : PassFail Grade : Pass 1. Submit 2. Summary 3. Reset 4.Display 5. Exit Enter choice: 1 Name >>Martie Score(0..100) >> Enter 1 for grade basis, o for pass/fail >>0 Name : Martie Score : 0 Status : PassFail Grade : Fail 1. Submit 2. Summary 3.Reset 4.Display 5.Exit Enter choice: 1 Name >>Mark Score(0..100) >>39 Enter 1 for grade basis, o for pass/fail >>0 Name : Mark Score : 39 Status : PassFail Grade : Fail 1. Submit 2. Summary 3.Reset 4.Display 5.Exit Enter choice: 1 Name >>Matthew Score(0..100) >>80 Enter 1 for grade basis, o for pass/fail >>0 Name : Matthew Score : 80 Status : PassFail Grade : Pass 1. Submit 2. Summary 3. Reset 4.Display 5. Exit Enter choice: 4 DISPLAY 1 Name | Score | Status | Grade | Martin Mary Martie Mark Matthew 99 PassFail | Pass | 100 PassFail | Pass | 0 PassFail | Fail | 39 PassFail | Fail | 80 PassFail | Pass | 1. Submit 2. Summary 3. Reset 4.Display 5. Exit 1. Submit 2. Summary 3. Reset 4.Display 5. Exit Enter choice: 4 DISPLAY | Name | Score | Status | Grade | 1 Martin Mary | Martie Mark Matthew Michael Misha Millie 99 PassFail | Pass | 100 PassFail | Pass 0 PassFail | Fail | 39| PassFail | Fail | 80 PassFail | Pass 1001 Graded 1 ol Graded | B 751 Graded B A
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
