Hi guys I am totally new in oop in python. I am trying to write a class of students that gets the number of students, their ages, their heights and their weights and store these information as 3 separate lists.
I aim to compute the average of ages and weights as well as heights. I don't have any problem so far.
In the next step I want to compare the average age of two instances of the class plus the average of the weights.
As it's an exercise in oop I should do it by a method of the class. But, I don't know that is it possible to do it using a method in the original class (class School) or I should create a subclass to compare the attributes of two instances of the School class.
Any help is really appreciated.
Here is my code:
class School:
avg_age = 0
avg_heigt = 0
avg_weight = 0
def __init__(self):
self.n =int(input())
self.list_ages = [float(x) for x in input().split(" ")]
self.list_higt = [float(x) for x in input().split(" ")]
self.list_weight = [float(x) for x in input().split(" ")]
def get_av(self):
School.avg_age = sum(self.list_ages) / len(self.list_ages)
School.avg_heigt = sum(self.list_higt)/len(self.list_higt)
Scoohl.avg_weight = sum(self.list_weight)/len(self.list_weight)
return("{},{},{}".format(School.avg_age,School.avg_heigt,School.avg_weight))