Created
July 11, 2016 19:30
-
-
Save ItsBerry/83fd3ed6685c4330dbbda61300d0346c to your computer and use it in GitHub Desktop.
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
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