# This will get executed each time the exercise gets initialized.
import numpy as np
import pandas as pd
import scipy.stats as stats
x = np.array(['R','R','R','R','R','R']*10)
n = len(x)
N = 1000
counts = np.random.binomial(n,0.5,N)
phat = counts/n
# libraries
import numpy as np
import pandas as pd
import scipy.stats as stats
# initialization code
dataphat = len(x[x == 'R'])/n
phatdf = pd.DataFrame(phat, columns = ['phat'])
meandist = phatdf['phat'].mean()
SEdist = phatdf['phat'].std()
# calculate z-statistic
z = ...
# left-tailed test
print('left-tailed p-value: ', stats.norm.cdf(...))
# right-tailed test
print('right-tailed p-value: ', stats.norm.cdf(...))
# libraries
import numpy as np
import pandas as pd
import scipy.stats as stats
# initialization code
dataphat = len(x[x == 'R'])/n
phatdf = pd.DataFrame(phat, columns = ['phat'])
meandist = phatdf['phat'].mean()
SEdist = phatdf['phat'].std()
# calculate z-statistic
z = (dataphat - 0.5)/SEdist
# left-tailed test
print('left-tailed p-value: ', stats.norm.cdf(z))
# right-tailed test
print('right-tailed p-value: ', stats.norm.cdf(-1*z))