Bird
0
0

Find the error in this code snippet:

medium📝 Debug Q14 of 15
SciPy - Statistical Functions (scipy.stats) Basics
Find the error in this code snippet:
from scipy.stats import norm
prob = norm.pdf(1, mean=0, scale=1)
print(prob)
AParameter 'mean' should be 'loc'
BMissing import statement
Cnorm.pdf does not exist
Dscale must be an integer
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter names for norm.pdf

    norm.pdf uses 'loc' for mean, not 'mean'. Using 'mean' causes an error.
  2. Step 2: Identify correct parameter

    Replace 'mean=0' with 'loc=0' to fix the code.
  3. Final Answer:

    Parameter 'mean' should be 'loc' -> Option A
  4. Quick Check:

    Use loc for mean in norm functions [OK]
Quick Trick: Use 'loc' not 'mean' for normal distribution mean [OK]
Common Mistakes:
MISTAKES
  • Using 'mean' instead of 'loc' parameter
  • Assuming norm.pdf is missing
  • Thinking scale must be integer

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes