There is one error in one of five blocks of a program. To find the error, we test three randomly selected blocks. Let $$ be the number of errors in these three blocks. Compute $E(X)$ and $Var(X)$.
That's what i've tried:
$p = 0.6$
$n = 1$
$E(X) = n\cdot p = 1\cdot (0.6) = 0.6$
$Var(X) = n \cdot p\cdot q = 1\cdot (0.6)\cdot (0.4) = 0.24$
If we were using $n = 2$ with success probability of $0.6$ we would have:
$P(X = 0) = 0.16$
$P(X = 1) = 0.48$
$P(X = 2) = 0.36$
$p = 0.6$
$n = 2$
$E(X) = 2\cdot (0.6) = 1.2$
$Var(X) = 2\cdot (0.6)\cdot (0.4) = 0.48$
Since there is one error in the 5 blocks of code, $X \in \{0,1\}$, where $X=0$ if all 3 blocks of code being tested are correct.
Assuming the error is equally likely to be in any of the 5 blocks of code, the probability of drawing three correct blocks of code is $\frac{4}{5} \times \frac{3}{4} \times \frac{2}{3} = \frac{2}{5}$, i.e. $P(X=0) = \frac{2}{5}$ and $P(X=1)=\frac{3}{5}$.
$\mathbb{E}[X] = 0 \times \frac{2}{5} + 1 \times \frac{3}{5} = \frac{3}{5}$.
$\mathbb{E}[X^2] = 0^2 \times \frac{2}{5} + 1^2 \times \frac{3}{5} = \frac{3}{5}$.
$Var(X) = \mathbb{E}[X^2] - \mathbb{E}[X]^2 = \frac{3}{5}-\left( \frac{3}{5} \right)^2 = \frac{6}{25}$.