Bird
0
0

What will be the output of this code snippet?

medium📝 Predict Output Q5 of 15
SciPy - Statistical Tests
What will be the output of this code snippet?
from scipy.stats import pearsonr
x = [10, 20, 30, 40, 50]
y = [15, 25, 35, 45, 55]
corr, p_val = pearsonr(x, y)
print(round(corr, 3))
A1.000
B0.000
C-1.000
D0.500
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the data

    Both x and y increase linearly with a perfect positive linear relationship.
  2. Step 2: Calculate Pearson correlation

    Since y is a perfect linear function of x (y = x + 5), the correlation coefficient is 1.
  3. Final Answer:

    1.000 -> Option A
  4. Quick Check:

    Perfect positive linear relation means correlation = 1 [OK]
Quick Trick: Perfect linear increase means correlation = 1 [OK]
Common Mistakes:
MISTAKES
  • Assuming correlation is zero without calculation
  • Confusing correlation with covariance
  • Rounding errors leading to wrong answers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes