Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
SciPy - Statistical Functions (scipy.stats) Basics
Identify the error in this code snippet:
import numpy as np
from scipy import stats
data = np.array([1, 2, 3, 4, 5])
percentile = stats.scoreatpercentile(data, 110)
print(percentile)
AData array must be sorted before calling scoreatpercentile
BPercentile value cannot be greater than 100
Cscoreatpercentile requires percentile as first argument
Dscoreatpercentile does not exist in scipy.stats
Step-by-Step Solution
Solution:
  1. Step 1: Check percentile argument validity

    Percentiles must be between 0 and 100 inclusive.
  2. Step 2: Identify error cause

    Passing 110 is invalid and will cause an error or unexpected behavior.
  3. Final Answer:

    Percentile value cannot be greater than 100 -> Option B
  4. Quick Check:

    Percentile range = 0 to 100 [OK]
Quick Trick: Percentiles must be between 0 and 100 [OK]
Common Mistakes:
MISTAKES
  • Passing percentile > 100
  • Assuming data must be sorted
  • Wrong argument order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes