For a big nbr of it might matter?
Is av_grade O(n*2) and the first O(n) when it comes to adding or is
"sum x for x in y" just traversing the list ones, accumulating the
values, it doesnt first build the list and then travese it for sum?
def averageGrade(se lf):
tot = 0
for review in self.reviews:
tot += review.grade
return tot / len(self.review s)
def av_grade(self):
return sum(review.grad e for review in self.reviews) / \
len(self.review s)
Is av_grade O(n*2) and the first O(n) when it comes to adding or is
"sum x for x in y" just traversing the list ones, accumulating the
values, it doesnt first build the list and then travese it for sum?
def averageGrade(se lf):
tot = 0
for review in self.reviews:
tot += review.grade
return tot / len(self.review s)
def av_grade(self):
return sum(review.grad e for review in self.reviews) / \
len(self.review s)
Comment