0
0
SciPydata~20 mins

Binomial distribution in SciPy - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Binomial Distribution Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of Binomial PMF Calculation
What is the output of this code that calculates the probability of exactly 3 successes in 10 trials with success probability 0.5 using scipy's binom.pmf?
SciPy
from scipy.stats import binom
result = binom.pmf(3, 10, 0.5)
print(round(result, 4))
A0.5000
B0.2051
C0.1172
D0.2500
Attempts:
2 left
💡 Hint
Recall that binom.pmf(k, n, p) gives the probability of k successes in n trials with success probability p.
data_output
intermediate
2:00remaining
Number of Trials with Probability Above Threshold
Using scipy's binom.pmf, how many values of k (from 0 to 10) have a probability greater than 0.1 for n=10 and p=0.3?
SciPy
from scipy.stats import binom
probabilities = binom.pmf(range(11), 10, 0.3)
count = sum(p > 0.1 for p in probabilities)
print(count)
A5
B3
C4
D6
Attempts:
2 left
💡 Hint
Calculate probabilities for k=0 to 10 and count how many exceed 0.1.
visualization
advanced
3:00remaining
Identify the Correct Binomial PMF Plot
Which option shows the correct plot of the binomial PMF for n=5 and p=0.6?
SciPy
import matplotlib.pyplot as plt
from scipy.stats import binom
import numpy as np

k = np.arange(0, 6)
pmf = binom.pmf(k, 5, 0.6)
plt.bar(k, pmf)
plt.xlabel('Number of successes')
plt.ylabel('Probability')
plt.title('Binomial PMF for n=5, p=0.6')
plt.show()
AA bar chart with highest bar at k=0 and probabilities summing to more than 1
BA line chart with decreasing values from k=0 to k=5
CA scatter plot with random points not matching binomial probabilities
DA bar chart with highest bar at k=3 and probabilities summing to 1
Attempts:
2 left
💡 Hint
Binomial PMF bars should sum to 1 and peak near np (here 5*0.6=3).
🧠 Conceptual
advanced
2:00remaining
Effect of Increasing Number of Trials on Binomial Distribution Shape
What happens to the shape of the binomial distribution when the number of trials n increases while keeping the success probability p fixed?
AThe distribution becomes more symmetric and approaches a normal distribution shape
BThe distribution becomes uniform across all outcomes
CThe distribution becomes more skewed to the left
DThe distribution becomes a single spike at k=0
Attempts:
2 left
💡 Hint
Think about the Central Limit Theorem and how binomial behaves for large n.
🔧 Debug
expert
2:00remaining
Identify the Error in Binomial PMF Calculation Code
What error does this code produce when trying to calculate the binomial PMF for k=3, n=10, p=0.5? from scipy.stats import binom result = binom.pmf(3, 0.5, 10) print(result)
SciPy
from scipy.stats import binom
result = binom.pmf(3, 0.5, 10)
print(result)
AValueError because probability p is out of range
BTypeError because parameters are in wrong order
CSyntaxError due to missing parentheses
DNo error, outputs correct probability
Attempts:
2 left
💡 Hint
Check the order of parameters for binom.pmf(k, n, p).