Skip to content

Instantly share code, notes, and snippets.

@ItsBerry
Created July 11, 2016 19:30
Show Gist options
  • Save ItsBerry/83fd3ed6685c4330dbbda61300d0346c to your computer and use it in GitHub Desktop.
Save ItsBerry/83fd3ed6685c4330dbbda61300d0346c to your computer and use it in GitHub Desktop.
from random import randint
class CoinFlipSimulator():
"""Simulate a coin flip of a specific amount of flips"""
def __init__(self, number_of_flips):
self.number_of_flips = number_of_flips
def simulation(self):
"""Perform the actual coin flips"""
self.sides_list = []
for _ in range(self.number_of_flips):
self.sides_list.append(randint(1,2))
def show_results(self):
"""Show the results of the coin flips"""
heads = self.sides_list.count(1)
tails = self.sides_list.count(2)
total = heads + tails
print("Heads: " + str(heads / total * 100))
print("Tails: " + str(tails / total * 100))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment