Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Get multiple student scores of a course and find the average score of the cou

ID: 3904706 • Letter: 1

Question

1. Get multiple student scores of a course and find the average score of the course. Use OOP. Design the class by UML and write python application to implement the solution.

2. Use the student.py and studentaverage.py codes to expand the solution by creating a new class called Course with a datafield of scores as list, setScores, getScores and getAverage methods. The setScores should get all the scores from the user repetitively until the user has entered all the scores. The getAverage should calculate the average of the course scores and return average score. Write the main application to create Course Object, call setScores method of Course, call getAverage method and print the result.

Explanation / Answer

class Course:
    def __init__(self,n):
       self.list = []
       self.size = n
   
    def setScores(self):
       for i in range(self.size):
          a = int(input("Enter score for",i,"student:")
          self.list.append(a);

    def getScores(self):
       return self.list

    def getAverage(self):
       sum = 0.0
       for i in range(self.size):
          sum = sum + self.list[i]
       return sum/self.size

def main():
     c = Course()
     c.setScore()
     print(c.getAverage()

main()