reorder structure

This commit is contained in:
Thomas Klaehn
2016-12-19 16:38:30 +01:00
committed by Thomas Klaehn
parent 2fc4339f61
commit 4d76bc4e88
34 changed files with 353 additions and 339 deletions

View File

@@ -0,0 +1,20 @@
class light_data:
def __init__(self, length=10):
self.max = length
self.data = []
def push(self, element):
if self.max == 0:
return False
if len(self.data) == self.max:
_ = self.data.pop(0)
self.data.append(element)
return True
def average(self):
if len(self.data) != self.max:
return None
return sum(self.data) / self.max
def length(self):
return len(self.data)