古人常說: 不經一事,不長一智
原本想趁最後一日悠閒的時光,
好好享受上飛機前的奧克蘭式浪漫,
和社長到處自駕遊玩,
逛逛公園,
看看海景,
吹吹風,
吃吃甜點,
沒想到一大早還是在北島發生了小插曲,
這能怪誰呢?
最自責的還是自己這部分吧!
只能當成一次經驗,
化作自己成長的養分,
以下是人生平均值累加程式:
import math
arr = [[44, 76, 12], [96, 12, 34, 53, 76, 34, 56, 86, 21], [34, 65, 34, 76, 34, 87, 34]]
def sum_average(arr):
n = 0
for i in arr:
n += sum(i) / int(len(i))
for j in i:
if len(arr) <= 50 and -100 < j < 100:
n = n
n = math.floor(n)
return n
print(sum_average(arr))
def sum_average_1(arr):
total = 0
for x in arr:
total += sum(x)/len(x)
return math.floor(total)
print(sum_average_1(arr))
def sum_average_2(arr):
n = 0
for i in arr:
n += sum(i) / int(len(i))
n = math.floor(n)
return n
print(sum_average_2(arr))
def sum_average_3(arr):
n = 0
for i in arr:
n += sum(i) / int(len(i))
for j in i:
if len(arr) <= 50 and -100 < j < 100:
n = n
else:
return False
n = math.floor(n)
return n
print(sum_average_3(arr))
def sum_average_4(arr):
n = 0
for i in arr:
n += sum(i) / int(len(i))
for j in i:
if len(arr) <= 50 and -100 <= j <= 100:
pass
else:
return False
n = math.floor(n)
return n
print(sum_average_4(arr))
#arr = [[3, 4, 1, 3, 5, 1, 4], [21, 54, 33, 21, 77]]
#
#print('-'*50)
#n = 0
#for i in arr:
# print(n)
# for j in i:
# if len(arr) <= 50 and -100 < j < 100:
# n += sum(i) / int(len(i))**2
# print(n)
#n = sum(arr[1]) / int(len(arr[1]))
#n = math.floor(n)
#print(n)
#
#print('-'*50)
#S = 44.0
#for i in range(3):
# S += 132 / 3**2
# print(S)
#print(S)
#for i in range(9):
# S += 468 / 9**2
# print(S)
#print(S)
input: [[44, 76, 12], [96, 12, 34, 53, 76, 34, 56, 86, 21], [34, 65, 34, 76, 34, 87, 34]]
output: 148