Skip to content

Commit

Permalink
Wrote flip_coin function
Browse files Browse the repository at this point in the history
  • Loading branch information
sberdianskyi committed Oct 27, 2023
1 parent 9ece647 commit 17f0af2
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
@@ -1 +1,18 @@
# write your code here
import random


def flip_coin():
num_simulations = 10000
num_flips = 10
results = {i: 0 for i in range(num_flips + 1)}

for _ in range(num_simulations):
num_heads = sum(random.choice([0, 1]) for _ in range(num_flips))
results[num_heads] += 1

percentage_results = {key: (value / num_simulations) * 100 for key, value in results.items()}

return percentage_results


print(flip_coin())

0 comments on commit 17f0af2

Please sign in to comment.