-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ece647
commit 489e1c4
Showing
1 changed file
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |