diff --git a/app/main.py b/app/main.py index fa56336e..bd7aa72d 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,26 @@ -# write your code here +import matplotlib.pyplot +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()] + matplotlib.pyplot.plot(xpoints, ypoints) + matplotlib.pyplot.title("Gaussian distribution") + matplotlib.pyplot.ylabel("Drop percentage %") + matplotlib.pyplot.xlabel("Heads count") + matplotlib.pyplot.show() diff --git a/requirements.txt b/requirements.txt index 3f202d6e..01ba4814 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,3 +4,4 @@ flake8-quotes==3.3.1 flake8-variables-names==0.0.5 pep8-naming==0.13.2 pytest==7.1.3 +matplotlib==3.9.4