Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

You only need to complete the sections that are indicated in the code. Output should be: The output of the program should look as follows:

You only need to complete the sections that are indicated in the code.
Output should be:
The output of the program should look as follows:
Name: Juan
Score 1 : 71
Score 2 : 84
Score 3 : 88
High Score: 88
Average: 81.000
Name: Bill
Score 1 : 88
Score 2 : 97
Score 3 : 95
High Score: 97
Average: 93.333
Name: Stacy
Score 1 : 97
Score 2 : 84
Score 3 : 85
High Score: 97
Average: 88.667
Name: Maria
Score 1 : 87
Score 2 : 94
Score 3 : 76
High Score: 94
Average: 85.667
Name: Charley
Score 1 : 95
Score 2 : 94
Score 3 : 83
High Score: 95
Average: 90.667
Fill in missing code:
class Student:
def __init__(self, n, nScores):
self.name = n
self.scores =[]
self.nScores = nScores
for idx in range(nScores):
self.scores.append(0)
def setScore(self, idx, grade):
self.scores[idx]= grade
#[create a function named getNumberOfScores that returns the current number of scores]
#[create a function named getName that returns the name of the student]
#[create a function named getHighScore that loops through all scores, determines highest and returns it]
#[create a function named getAverage that sums all the scores, divides them by the number of scores, and returns the result]
def main(numScores =3):
from random import randint
"""Tests sorting."""
# Create the list and put 5 students into it
students = list()
names =("Juan", "Bill", "Stacy", "Maria", "Charley")
for name in names:
s = Student(name, numScores)
for index in range(numScores):
s.setScore(index, randint(70,100))
students.append(s)
# Print the contents
for s in students:
print ("Name: ","%-32s"% s.getName())
for score in range(numScores):
print ("Score ", score+1,":", s.scores[score])
print ("High Score: ", s.getHighScore())
print ("Average: %0.3f
"% s.getAverage())
if __name__=="__main__":
main()

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

Step: 3

blur-text-image

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

DB2 11 The Ultimate Database For Cloud Analytics And Mobile

Authors: John Campbell, Chris Crone, Gareth Jones, Surekha Parekh, Jay Yothers

1st Edition

1583474013, 978-1583474013

More Books

Students also viewed these Databases questions