Bird
0
0

What is the output of this code snippet?

medium📝 Predict Output Q4 of 15
SciPy - Statistical Tests
What is the output of this code snippet?
from scipy.stats import spearmanr
x = [10, 20, 30, 40, 50]
y = [5, 15, 25, 35, 45]
result = spearmanr(x, y)
print(round(result.correlation, 2))
A0.0
B1.0
C-1.0
D0.5
Step-by-Step Solution
Solution:
  1. Step 1: Understand input data relationship

    Both x and y increase together perfectly in order, so their ranks are perfectly correlated.
  2. Step 2: Calculate Spearman correlation

    Since ranks match exactly, Spearman correlation is 1.0, indicating perfect positive monotonic relationship.
  3. Final Answer:

    1.0 -> Option B
  4. Quick Check:

    Perfectly increasing sequences have Spearman correlation = 1.0 [OK]
Quick Trick: Perfectly matching ranks give correlation 1.0 [OK]
Common Mistakes:
MISTAKES
  • Confusing Spearman with Pearson correlation
  • Expecting zero or negative correlation
  • Rounding errors causing confusion

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes