Skip to content
DeepForgeby svx
All problems
EasyProbabilitypr-010

Binomial Mean and Variance

Problem

For a binomial random variable with n trials and success probability p, return the mean and variance as a two-element list.

mean = n * p and variance = n * p * (1 - p).

Test cases

case 1
in: [10,0.5]
expected: [5,2.5]
case 2
in: [1,0.3]
expected: [0.3,0.21]
case 3
in: [0,0.9]
expected: [0,0]
case 4
in: [100,0.01]
expected: [1,0.99]
Starter codePython
def binomial_mean_variance(n, p):
    # Your code here
    pass

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