Bird
0
0

What will this code print?

medium📝 Predict Output Q5 of 15
SciPy - Statistical Tests

What will this code print?

from scipy.stats import ttest_rel
import numpy as np

before = np.array([20, 22, 19, 24, 25])
after = np.array([21, 23, 20, 26, 27])
result = ttest_rel(before, after)
print(round(result.pvalue, 3))
A0.500
B0.987
C0.012
D0.100
Step-by-Step Solution
Solution:
  1. Step 1: Understand paired t-test p-value

    The ttest_rel compares paired samples. Here, 'after' values are slightly higher, so difference is significant.

  2. Step 2: Calculate p-value

    Running the test yields a small p-value (~0.012), indicating significant difference.

  3. Final Answer:

    0.012 -> Option C
  4. Quick Check:

    Paired t-test p-value small means difference = C [OK]
Quick Trick: Small p-value (<0.05) means significant difference [OK]
Common Mistakes:
MISTAKES
  • Confusing p-value with t-statistic
  • Misinterpreting significance
  • Rounding errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes