Bird
0
0

Identify the error in this code snippet that attempts to perform a KS test:

medium📝 Debug Q14 of 15
SciPy - Statistical Tests
Identify the error in this code snippet that attempts to perform a KS test:
from scipy.stats import ks_2samp
sample1 = [1, 2, 3]
sample2 = [4, 5, 6]
result = ks_2samp(sample1)
print(result.statistic)
AIncorrect import statement for ks_2samp
BMissing second sample argument in ks_2samp call
CUsing print instead of return to show result
DSamples contain integers instead of floats
Step-by-Step Solution
Solution:
  1. Step 1: Check function call parameters

    ks_2samp requires two sample arguments, but only one is given.
  2. Step 2: Identify the error cause

    Missing second sample causes a TypeError because the function expects two inputs.
  3. Final Answer:

    Missing second sample argument in ks_2samp call -> Option B
  4. Quick Check:

    ks_2samp needs two samples [OK]
Quick Trick: ks_2samp always needs two sample inputs [OK]
Common Mistakes:
MISTAKES
  • Forgetting the second sample argument
  • Thinking print causes error
  • Assuming integer samples cause error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes