Bird
0
0

What is the output of this code snippet?

medium📝 Predict Output Q4 of 15
SciPy - Statistical Functions (scipy.stats) Basics
What is the output of this code snippet?
from scipy.stats import binom
n, p = 4, 0.3
prob = binom.pmf(2, n, p)
print(round(prob, 3))
A0.345
B0.411
C0.264
D0.123
Step-by-Step Solution
Solution:
  1. Step 1: Calculate binomial PMF for k=2, n=4, p=0.3

    Using formula or scipy, probability = C(4,2) * 0.3^2 * 0.7^2 = 6 * 0.09 * 0.49 = 0.2646 approx.
  2. Step 2: Round the result to 3 decimals

    Rounded to 3 decimals, 0.2646 becomes 0.264.
  3. Final Answer:

    0.264 -> Option C
  4. Quick Check:

    binom.pmf(2,4,0.3) ≈ 0.264 [OK]
Quick Trick: Use scipy or formula to get exact PMF value [OK]
Common Mistakes:
MISTAKES
  • Incorrect combination calculation
  • Rounding errors
  • Mixing p and 1-p powers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes