From 5a651680ab7db9b3c6038c801f484450227784e7 Mon Sep 17 00:00:00 2001 From: Vladyslav Shatrovskyi Date: Mon, 23 Oct 2023 20:58:13 +0300 Subject: [PATCH] Solution --- app/main.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index fa56336e..863fb7fe 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,15 @@ -# write your code here +import random + + +def flip_coin() -> dict: + conducts = 10000 + + data = {key: 0 for key in range(11)} + for _ in range(conducts): + random_cases = [random.randint(0, 1) for i in range(10)] + flip = random_cases.count(1) + data[flip] += 1 + + result = {key: (value / conducts) * 100 for key, value in data.items()} + + return result