From cebc60d131ec3a8c9783d3f21b356a0a77ebe3dd Mon Sep 17 00:00:00 2001 From: Daniel <59575049+lemoentjiez@users.noreply.github.com> Date: Sun, 11 Dec 2022 20:12:32 +0200 Subject: [PATCH] Update seventh.py --- LabPSA_2/seventh.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/LabPSA_2/seventh.py b/LabPSA_2/seventh.py index 8b13789..641868b 100644 --- a/LabPSA_2/seventh.py +++ b/LabPSA_2/seventh.py @@ -1 +1,20 @@ +import random +import matplotlib.pyplot as plt + +tries = 1000 +number_of_n = {x: 0 for x in range(35, 65)} + +for x in range(tries): + heads = 0 + for z in range(100): + if random.randint(0, 1) == 1: + heads += 1 + if heads in number_of_n: + number_of_n[heads] += 1 + +x = list(number_of_n.keys()) +y = list(number_of_n.values()) + +plt.bar(x, y, color ='maroon', width = 0.4) +plt.show()