Skip to content
DeepForgeby svx
All problems
MediumStatisticsst-383

Binomial PMF Value

Problem

The binomial pmf is C(n, k) p^k (1 - p)^(n - k).

Given n, k, and p, return the probability of exactly k successes. Use math.comb for the binomial coefficient.

Hint

Exact k successes, not at most k.

Test cases

case 1
in: [10,5,0.5]
expected: 0.24609375
case 2
in: [4,0,0.2]
expected: 0.4096000000000001
case 3
in: [5,2,0.5]
expected: 0.3125
Starter codePython
def binomial_pmf_value(n, k, p):
    # Your code here
    pass

3 test cases · run your code against them in the editor