@@ -0,0 +1,12 @@ | |||
def mean(*params): | |||
x = 0 | |||
sum = 0 | |||
for curr in params: | |||
sum += curr | |||
x += 1 | |||
return sum/x | |||
#alternativ: return sum/len(params) | |||
print("Mittelwert aus 3, 6, 9, 10, 18, 22: ", mean(3, 6, 9, 10, 18, 22)) | |||
print("Mittelwert aus 1.2, 3.8, 9.0, 2, 25, 3.6: ", mean(1.2, 3.8, 9.0, 2, 25, 3.6)) |