class RingStorage: def __init__(self, n): self.n = n self.c = 0 self.filled = 0 self.list = list(0 for i in range(n)) def addContent(self, z): self.list[self.c]=z self.c = (self.c+1) % self.n self.filled = self.filled + 1 if (self.filled > self.n): self.filled = self.n def printSto(self): print(self.list) def getMedium(self): sum = 0 for i in range(self.n): sum = sum + self.list[i] if (self.filled > 0): return sum / self.filled else: return -99