from random import randint
# We're going to make a bag of 3,000,000 red marbles and 1,000,000 blue marbles.
# 0 means red, 1 means blues
bag_of_marbles = 3_000_000*[0]+1_000_000*[1]
number_of_blue = sum(bag_of_marbles)
total_marbles = len(bag_of_marbles)
number_of_red = total_marbles - number_of_blue
print(f"The number of blue marbles in our population is: {number_of_blue}")
print(f"The number of red marbles in our population is: {number_of_red}")
# We're now going to choose 1000 of them at random.
random_sample = []
sample_size = 1000
for i in range(sample_size):
# This basically picks one marble at random and adds it to sample
random_sample.append(bag_of_marbles[randint(0,len(bag_of_marbles))])
total_samples = len(random_sample)
sample_blue = sum(random_sample)
sample_red = total_samples - sample_blue
print(f"Sample size: {total_samples}")
print(f"Number of blue marbles in our sample: {sample_blue}")
print(f"Number of red marbles in our sample: {sample_red}")
print(f"Percentage of blue marbles in our population: {sample_blue / total_samples*100:.2f}%")
print(f"Percentage of red marbles in our population: {sample_red / total_samples*100:.2f}%")