#
# your solution is here
#
from random import randrange

def experiment(n):
    num_tails = 0
    num_heads = 0
    for i in range(n):
        if(randrange(2) == 0): # 0 is the head
            num_heads += 1
        else:
            num_tails += 1
    return num_heads, num_tails

num_heads1000, num_tails1000 = experiment(1000)
print("Experiment with 1000 flips | heads: " + str(num_heads1000) + " tails: " + str(num_tails1000)) 
print("Probability | heads: " + str(num_heads1000/1000) + " tails: " + str(num_tails1000/1000))
num_heads10000, num_tails10000 = experiment(10000)
print("Experiment with 10,000 flips | heads: " + str(num_heads10000) + " tails: " + str(num_tails10000)) 
print("Probability | heads: " + str(num_heads10000/10000) + " tails: " + str(num_tails10000/10000))
num_heads100000, num_tails100000 = experiment(100000)
print("Experiment with 100,000 flips | heads: " + str(num_heads100000) + " tails: " + str(num_tails100000)) 
print("Probability | heads: " + str(num_heads100000/1000000) + " tails: " + str(num_tails100000/1000000))

#
# your solution is here
#

def experiment(n):
    num_tails = 0
    num_heads = 0
    for i in range(n):
        if(randrange(5) < 2): # < 0.4 prob for tail
            num_tails += 1
        else:
            num_heads += 1
    return num_heads, num_tails

num_heads1000, num_tails1000 = experiment(1000)
print("Experiment with 1000 flips | heads: " + str(num_heads1000) + " tails: " + str(num_tails1000)) 
print("Probability | heads: " + str(num_heads1000/1000) + " tails: " + str(num_tails1000/1000))
num_heads10000, num_tails10000 = experiment(10000)
print("Experiment with 10,000 flips | heads: " + str(num_heads10000) + " tails: " + str(num_tails10000)) 
print("Probability | heads: " + str(num_heads10000/10000) + " tails: " + str(num_tails10000/10000))
num_heads100000, num_tails100000 = experiment(100000)
print("Experiment with 100,000 flips | heads: " + str(num_heads100000) + " tails: " + str(num_tails100000)) 
print("Probability | heads: " + str(num_heads100000/1000000) + " tails: " + str(num_tails100000/1000000))
# proportion of heads and tails
print(str((num_heads100000)/(num_tails100000)))

