From 95b84517e8f623f6fe4740d9611c607ac8f04412 Mon Sep 17 00:00:00 2001 From: Jonka Date: Sat, 6 Oct 2018 10:47:22 +0200 Subject: [PATCH] =?UTF-8?q?Das=20ist=20ein=20Commit-Test=20f=C3=BCr=20Jank?= =?UTF-8?q?o?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Tag2_MittelwertAusVariablerAnzahlParameter.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 Tag2_MittelwertAusVariablerAnzahlParameter.py diff --git a/Tag2_MittelwertAusVariablerAnzahlParameter.py b/Tag2_MittelwertAusVariablerAnzahlParameter.py new file mode 100644 index 0000000..1c97adf --- /dev/null +++ b/Tag2_MittelwertAusVariablerAnzahlParameter.py @@ -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)) \ No newline at end of file