0 Members and 1 Guest are viewing this topic.
def f(x): d = [] if x == d: return None else: sum = 0 for n in d: sum = sum + n length = len(d) total = sum/length print(total)
def calcAverage(_array): if _array: _sum = 0 for i in _array: _sum += i average = _sum/len(_array) return average else: return None
<phil> I'm gonna DDOS the washing machine with clothes packets.<deviant_sheep> dont use too much soap or youll cause a bubble overflow
if type(myarray) is list and len(myarray) > 0 :sum(myarray)/len(myarray) == sum([x for x in myarray]) / len(myarray) == reduce(lambda x,y: x+y,myarray) / len(myarray)
l = [1, 2, 3, 4, 5, 6, 7, 8]average = reduce(lambda x, y: x + y, l) / float(len(l))