# libraries import numpy as np import pandas as pd import scipy.stats as stats # draw some cards x = np.array([...]) # calculate the p-value n = len(x) N = 1000 counts = np.random.binomial(n,0.5,N) phat = counts/n dataphat = len(x[x == 'R'])/n phatdf = pd.DataFrame(phat, columns = ['phat']) print('p-value: ', ...) # libraries import numpy as np import pandas as pd import scipy.stats as stats # draw some cards x = np.array(['R','R','R','R','R','R']) # calculate the p-value n = len(x) N = 1000 counts = np.random.binomial(n,0.5,N) phat = counts/n dataphat = len(x[x == 'R'])/n phatdf = pd.DataFrame(phat, columns = ['phat']) print('p-value: ', len(phatdf[phatdf['phat'] >= dataphat])/N)