From 4c913032650b8464cc99de6f0dd9697c31c2a7e0 Mon Sep 17 00:00:00 2001 From: Kateryna Date: Mon, 23 Dec 2024 20:16:21 +0200 Subject: [PATCH 1/2] Solution --- app/main.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index fa56336e..a60175ec 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,31 @@ -# write your code here +import random +import matplotlib.pyplot as plt +import numpy as np + + +def flip_coin() -> dict: + result = {i: 0 for i in range(11)} + cases = 10000 + + for case in range(cases): + streak_result = [] + + for num in range(10): + streak_result.append(random.randint(0, 1)) + + key = streak_result.count(0) + result[key] += 1 + + final_result = {key: round(value / cases * 100, 2) + for key, value in result.items()} + return final_result + + +def draw_gaussian_distribution_graph(values: dict) -> None: + keys = [num for num in values.keys()] + values = [num for num in values.values()] + xpoints = np.array(keys) + ypoints = np.array(values) + + plt.plot(xpoints, ypoints) + plt.show() From d595f8888be313dbbc73c68d3ac3ef0e3d2f74df Mon Sep 17 00:00:00 2001 From: Kateryna Date: Mon, 23 Dec 2024 20:21:38 +0200 Subject: [PATCH 2/2] add requirements --- requirements.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/requirements.txt b/requirements.txt index 3f202d6e..738dc01e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,6 @@ flake8-quotes==3.3.1 flake8-variables-names==0.0.5 pep8-naming==0.13.2 pytest==7.1.3 + +matplotlib~=3.10.0 +numpy~=2.2.1 \ No newline at end of file