I have a problem of solving to get the average of 1st quarter, 2nd quarter, 3rd quarter and 4th quarter of list and this is the code.
class Students:
def __init__(self):
self.studName = []
self.gender = []
self.stQ = []
self.ndQ = []
self.rdQ = []
self.thQ = []
def newStudent(self,newStud,studGender):
self.studName.append(newStud)
self.gender.append(studGender)
def studGrades(self,first,second,third,fourth):
self.stQ.append(first)
self.ndQ.append(second)
self.rdQ.append(third)
self.thQ.append(fourth)
print("Student Grade 1st Quarter: ", first)
print("Student Grade 2nd Quarter: ", second)
print("Student Grade 3rd Quarter: ", third)
print("Student Grade 4th Quarter: ", fourth)
#average
def Average(self):
for i in self.stQ,self.ndQ,self.rdQ,self.thQ:
sums = self.stQ[i] + self.ndQ[i] + self.rdQ[i] + self.thQ[i]
avg = sums / 4
print(avg)
class Students:
    def __init__(self):
        self.studName = []
        self.gender = []
        self.stQ = []
        self.ndQ = []
        self.rdQ = []
        self.thQ = []
    def newStudent(self, newStud, studGender):
        self.studName.append(newStud)
        self.gender.append(studGender)
    def studGrades(self, first, second, third, fourth):
        self.stQ.append(first)
        self.ndQ.append(second)
        self.rdQ.append(third)
        self.thQ.append(fourth)
        print("Student Grade 1st Quarter: ", first)
        print("Student Grade 2nd Quarter: ", second)
        print("Student Grade 3rd Quarter: ", third)
        print("Student Grade 4th Quarter: ", fourth)
    # average
    def Average(self):
        for i in range(len(self.stQ)):
            sums = self.stQ[i] + self.ndQ[i] + self.rdQ[i] + self.thQ[i]
            avg = sums / 4
            print(avg)
obj = Students()
obj.newStudent("Will", "male")
obj.studGrades(85, 77, 90, 100)
obj.Average()
Comments