Question: Write a Python program for each of the problems in this lab. Program 1 A simple course management system models a students information with a
Write a Python program for each of the problems in this lab.
Program 1
A simple course management system models a students information with a name and a set of scores. This system should be able to create a student object with a given name and a number of scores, all of which will be 0 at startup. The system should be able to access or replace a score at a given position (counting from 0), obtain the number of scores, obtain the highest score, obtain the average score, and obtain the students name. In addition, the system should have a method to display name, scores, highest score and average score of a student. Please define a class named Student to implement this course management system. Please use the starter code student.py.
student.py starter code:
class Student(object): """Represents a student.""" def __init__(self, name = "", numberOfScores = 3): """All scores are initially 0.""" def display(self): """Display name, scores, highest and average score of the student.""" def getNumberOfScores(self): """Returns the number of scores.""" def getName(self): """Returns the student's name.""" def setScore(self, i, score): """Resets the ith score, counting from 0.""" def getScore(self, i): """Returns the ith score, counting from 0.""" def getAverage(self): """Returns the average score.""" def getHighScore(self): """Returns the highest score.""" from random import randint def main(numScores = 3): """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 print("The list of students: ") for s in students: s.display() if __name__ == "__main__": main()
Expected Output:


Expected output: The list of students: Name: Juan Scores: 71 75 89 Highest score: 89.00 Average score: 78.33 Name: Bill Scores: 97 89 90 Highest score: 97.00 Average score: 92.00 Name: Stacy Scores: 99 83 87 Highest score: 99.00 Average score: 89.67 Name: Maria Scores: 73 97 92 Highest score: 97.00 Average score: 87.33 Name: Charley Scores: 95 89 92 Highest score: 95.00 Average score: 92.00
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
