This program tests if the average score with the new method is higher than 75.
import numpy as np
from scipy import stats
# Suppose we want to test if a new teaching method improves test scores
# Hypothesis: New method improves scores (mean > 75)
# Sample scores from students using new method
scores = np.array([78, 82, 85, 79, 90, 88, 76, 84])
# Perform one-sample t-test against 75
stat, p_value = stats.ttest_1samp(scores, 75)
# Since we want mean > 75, use one-sided p-value
p_value_one_sided = p_value / 2 if stat > 0 else 1 - p_value / 2
print(f"Test statistic: {stat:.3f}")
print(f"One-sided p-value: {p_value_one_sided:.3f}")
# Decide if new method improves scores at 0.05 significance
if p_value_one_sided < 0.05:
print("We have evidence that the new method improves scores.")
else:
print("We do not have enough evidence to say the new method improves scores.")