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() 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