Bird
0
0

What is the output of this code?

medium📝 Predict Output Q4 of 15
SciPy - Statistical Tests
What is the output of this code?
from scipy.stats import pearsonr
x = [1, 2, 3, 4]
y = [4, 3, 2, 1]
result = pearsonr(x, y)
print(round(result[0], 2))
A-1.00
B1.00
C0.00
D0.50
Step-by-Step Solution
Solution:
  1. Step 1: Understand data relationship

    x increases from 1 to 4, y decreases from 4 to 1, so they have a perfect negative linear relationship.
  2. Step 2: Calculate Pearson correlation

    Perfect negative linear relationship means correlation is -1.00.
  3. Final Answer:

    -1.00 -> Option A
  4. Quick Check:

    Perfect negative correlation = -1.00 [OK]
Quick Trick: Opposite trends give -1 correlation [OK]
Common Mistakes:
MISTAKES
  • Assuming positive correlation for increasing x
  • Ignoring order of y values
  • Rounding errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes