-
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 4c91303
Showing
1 changed file
with
31 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,31 @@ | ||
# write your code here | ||
import random | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
|
||
|
||
def flip_coin() -> dict: | ||
result = {i: 0 for i in range(11)} | ||
cases = 10000 | ||
|
||
for case in range(cases): | ||
streak_result = [] | ||
|
||
for num in range(10): | ||
streak_result.append(random.randint(0, 1)) | ||
|
||
key = streak_result.count(0) | ||
result[key] += 1 | ||
|
||
final_result = {key: round(value / cases * 100, 2) | ||
for key, value in result.items()} | ||
return final_result | ||
|
||
|
||
def draw_gaussian_distribution_graph(values: dict) -> None: | ||
keys = [num for num in values.keys()] | ||
values = [num for num in values.values()] | ||
xpoints = np.array(keys) | ||
ypoints = np.array(values) | ||
|
||
plt.plot(xpoints, ypoints) | ||
plt.show() |