Other types of distributions have expected values and variances based on the given parameters, just like the Poisson distribution. Recall that the Binomial distribution has parameters n, representing the number of events and p, representing the probability of “success” (or the specific outcome we are looking for occurring).

Consider the following scenario: we flip a fair coin 10 times and count the number of heads we observe. How many heads would you expect to see? You might naturally think 5, and you would be right! What we are doing is calculating the expected value without even realizing it. We take the 10 coin flips and multiply it by the chance of getting heads, or one-half, getting the answer of 5 heads. And that is exactly the equation for the expected value of the binomial distribution:

Expected(#ofHeads)=E(X)=n×pExpected(\#\;of\;Heads) = E(X) = n \times p

Note that if we were counting the number of heads out of 5 fair coin flips, the expected value would be:

5×0.5=2.55 \times 0.5 = 2.5

It is ok for the expected value to be a fraction or have decimal values, though it would be impossible to observe 2.5 heads.

Let’s look at a different example. Let’s say we forgot to study, and we are going to guess B on all 20 questions of a multiple-choice quiz. If we assume that every letter option (A, B, C, and D) has the same probability of being the right answer for each question, how many questions would we expect to get correct? n would equal 20, because there are 20 questions, and p would equal 0.25, because there is a 1 in 4 chance that B will be the right answer. Using the equation, we can calculate:

Expected(#rightanswers)=E(X)=20×0.25=5Expected(\#\;right\;answers) = E(X) = 20 \times 0.25 = 5



A certain basketball player has an 85% chance of making a given free throw and takes 20 free throws.

Uncomment expected_baskets and set it equal to the number of free throws they are expected to make.

Then print expected_baskets.


Let’s say a student has a 98% chance of arriving early or on time to class. Uncomment the variable called expected_late and set it equal to the expected number of times the student will arrive late to class throughout the 180 school days in a school year.

Be sure to print expected_late.

Take this course for free

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?