import math def normal_cdf(x): return 0.5 * (1 + math.erf(x / math.sqrt(2))) def two_tailed_p_value(z): return 2 * (1 - normal_cdf(abs(z))) z = 2.14 # observed test statistic p = two_tailed_p_value(z) print("Two-tailed p-value:", round(p, 4))
Click Run to execute this code.