From 0643bd397ea0521b49d7e507a7c7ea916f607bf6 Mon Sep 17 00:00:00 2001 From: AntonKrinichnyi Date: Thu, 19 Dec 2024 17:32:35 +0200 Subject: [PATCH 1/5] Solution --- app/main.py | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index fa56336e..fdc68c51 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,26 @@ -# write your code here +import matplotlib.pyplot as plt +import random + + +def flip_coin() -> list[int, float]: + coin_values = ["heads", "tails"] + result = {i: 0 for i in range(11)} + for _ in range(10000): + counter = 0 + for _ in range(10): + if random.choice(coin_values) == "heads": + counter += 1 + result[counter] += 1 + return {key: round(((result[key] / 10000) * 100), 2) + for key in result.keys()} + + +def draw_gaussian_distribution_graph() -> None: + coordinates = flip_coin() + xpoints = [key for key in coordinates.keys()] + ypoints = [value for value in coordinates.values()] + plt.plot(xpoints, ypoints) + plt.title("Gaussian distribution") + plt.ylabel("Drop percentage %") + plt.xlabel("Heads count") + plt.show() From e60e2acbed15cb20e2d97c71deb78f7d76dd72e3 Mon Sep 17 00:00:00 2001 From: AntonKrinichnyi Date: Thu, 19 Dec 2024 17:43:10 +0200 Subject: [PATCH 2/5] Solution --- app/main.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/app/main.py b/app/main.py index fdc68c51..bd7aa72d 100644 --- a/app/main.py +++ b/app/main.py @@ -1,4 +1,4 @@ -import matplotlib.pyplot as plt +import matplotlib.pyplot import random @@ -19,8 +19,8 @@ def draw_gaussian_distribution_graph() -> None: coordinates = flip_coin() xpoints = [key for key in coordinates.keys()] ypoints = [value for value in coordinates.values()] - plt.plot(xpoints, ypoints) - plt.title("Gaussian distribution") - plt.ylabel("Drop percentage %") - plt.xlabel("Heads count") - plt.show() + matplotlib.pyplot.plot(xpoints, ypoints) + matplotlib.pyplot.title("Gaussian distribution") + matplotlib.pyplot.ylabel("Drop percentage %") + matplotlib.pyplot.xlabel("Heads count") + matplotlib.pyplot.show() From 580963bebc375ede30b4ef31f1f2ef0c8d8efa32 Mon Sep 17 00:00:00 2001 From: AntonKrinichnyi Date: Thu, 19 Dec 2024 19:24:29 +0200 Subject: [PATCH 3/5] Solution --- app/main.py | 4 ++++ requirements.txt | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index bd7aa72d..e4bc7f6c 100644 --- a/app/main.py +++ b/app/main.py @@ -24,3 +24,7 @@ def draw_gaussian_distribution_graph() -> None: matplotlib.pyplot.ylabel("Drop percentage %") matplotlib.pyplot.xlabel("Heads count") matplotlib.pyplot.show() + + +print(flip_coin()) +draw_gaussian_distribution_graph() diff --git a/requirements.txt b/requirements.txt index 3f202d6e..67453085 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,6 +1,7 @@ -flake8==5.0.4 +lake8==5.0.4 flake8-annotations==2.9.1 flake8-quotes==3.3.1 flake8-variables-names==0.0.5 pep8-naming==0.13.2 pytest==7.1.3 +matplotlib==3.9.4 From 37b56b7c52b3b21265bf8cf1fc4e4dc8614e4bba Mon Sep 17 00:00:00 2001 From: AntonKrinichnyi Date: Thu, 19 Dec 2024 19:24:47 +0200 Subject: [PATCH 4/5] Solution --- app/main.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/app/main.py b/app/main.py index e4bc7f6c..bd7aa72d 100644 --- a/app/main.py +++ b/app/main.py @@ -24,7 +24,3 @@ def draw_gaussian_distribution_graph() -> None: matplotlib.pyplot.ylabel("Drop percentage %") matplotlib.pyplot.xlabel("Heads count") matplotlib.pyplot.show() - - -print(flip_coin()) -draw_gaussian_distribution_graph() From dc7e6c8b9dabdc636bae1aef4f2add4a07400ac1 Mon Sep 17 00:00:00 2001 From: AntonKrinichnyi Date: Thu, 19 Dec 2024 19:26:11 +0200 Subject: [PATCH 5/5] Solution --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 67453085..01ba4814 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -lake8==5.0.4 +flake8==5.0.4 flake8-annotations==2.9.1 flake8-quotes==3.3.1 flake8-variables-names==0.0.5