Bird
0
0

Examine this code snippet:

medium📝 Debug Q6 of 15
SciPy - Statistical Tests
Examine this code snippet:
from scipy.stats import mannwhitneyu
x = [3, 5, 7]
y = [2, 4, 6]
result = mannwhitneyu(x, y, alternative='less', use_continuity=True)
print(result.statistic, result.pvalue)

What is the issue with this code?
AThe alternative hypothesis 'less' is invalid for mannwhitneyu
BThe parameter 'use_continuity' is deprecated and should not be used
CThe samples x and y must be numpy arrays, not lists
DThe print statement should use result.stat instead of result.statistic
Step-by-Step Solution
Solution:
  1. Step 1: Check parameters of mannwhitneyu

    In recent scipy versions, the parameter 'use_continuity' has been deprecated and removed.
  2. Step 2: Validate alternative parameter

    'less' is a valid alternative hypothesis option.
  3. Step 3: Input types

    Lists are acceptable inputs; conversion to numpy arrays is not mandatory.
  4. Step 4: Attribute names

    The result object has attributes 'statistic' and 'pvalue', not 'stat'.
  5. Final Answer:

    The parameter 'use_continuity' is deprecated and should not be used -> Option B
  6. Quick Check:

    Check scipy docs for deprecated parameters [OK]
Quick Trick: Avoid deprecated parameters like use_continuity [OK]
Common Mistakes:
MISTAKES
  • Using deprecated parameters without checking docs
  • Confusing attribute names of result object
  • Assuming lists are invalid inputs

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes