From a1e1bc920bde17c3f76df6369e00c78dc4ebf0a7 Mon Sep 17 00:00:00 2001 From: Dmytro Prokhach Date: Wed, 1 Nov 2023 13:57:53 +0200 Subject: [PATCH] done --- app/main.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/app/main.py b/app/main.py index fa56336e..b5a36783 100644 --- a/app/main.py +++ b/app/main.py @@ -1 +1,14 @@ -# write your code here +import random + + +def flip_coin() -> dict: + some_list = {} + for i in range(10000): + count_of_heads = 0 + for _ in range(10): + count_of_heads += random.randint(1, 2) == 1 + if count_of_heads not in some_list: + some_list[count_of_heads] = 0 + some_list[count_of_heads] += 1 + return {count_of_heads: total / 10000 * 100 + for count_of_heads, total in some_list.items()}