Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #1229

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1 +1,36 @@
# write your code here
import random
import matplotlib.pyplot as plt


def flip_coin_ten_times() -> int:
coin = ["head", "tail"]
head_counter = 0
for i in range(10):
if random.choice(coin) == "head":
head_counter += 1
return head_counter


def flip_coin() -> dict:
flip_dict = {}
total_cases = 10000
for i in range(total_cases):
head_number = flip_coin_ten_times()
if head_number not in flip_dict:
flip_dict[head_number] = 1
else:
flip_dict[head_number] += 1

for key in flip_dict:
flip_dict[key] = round((flip_dict[key] / total_cases) * 100, 2)
sorted_flip_dict = dict(sorted(flip_dict.items()))

return sorted_flip_dict


def draw_gaussian_distribution_graph() -> None:
plt.ylim(0, 100)
plt.xlim(0, 10)
plt.ylabel("Drop percentage %")
plt.xlabel("Heads count")
plt.title("Gaussian")
Loading