Skip to content

Commit

Permalink
flip coin stats
Browse files Browse the repository at this point in the history
  • Loading branch information
valerii-kashpur committed Dec 19, 2024
1 parent 9ece647 commit 489e1c4
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# write your code here
import random


def flip_10_times() -> int:
return sum([random.randint(0, 1) for _ in range(10)])


def flip_coin() -> dict[int, float | int]:
heads_count = {i: 0 for i in range(11)}
simulations_count = 10_000

for _ in range(0, simulations_count):
heads = flip_10_times()
heads_count[heads] += 1

result = {key: (count / simulations_count) * 100 for key, count in
heads_count.items()}

return result

0 comments on commit 489e1c4

Please sign in to comment.