diff --git a/app/main.py b/app/main.py index fa56336e..8ba808b0 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() -> dict: + result = {i: 0.0 for i in range(11)} + for _ in range(10000): + flip_res = [random.choice([0, 1]) for _ in range(10)] + head = sum(flip_res) + result[head] += 1 + + for key in result: + result[key] = round((result[key] / 10000) * 100, 2) + + return result + + +def draw_gaussian_distribution_graph(result: dict) -> None: + x_ = list(result.keys()) + y_ = list(result.values()) + + plt.plot(x_, y_) + plt.title("Gaussian Distribution") + plt.xlabel("Heads count") + plt.ylabel("Drop percentage") + plt.show() diff --git a/requirements.txt b/app/requirements.txt similarity index 88% rename from requirements.txt rename to app/requirements.txt index 3f202d6e..afff6807 100644 --- a/requirements.txt +++ b/app/requirements.txt @@ -3,4 +3,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 +pytest==7.1.3 \ No newline at end of file