Let $Y$ = $pD_1+(1-p)D_2$, where $Y, D_1, D_2$ are random variables such that $D_1$ and $D_2$ are independent, and $p$ is a fixed parameter, $p\in(0,1)$.
I computed $$var(Y) = var[pD_1+(1-p)D_2)] = p^2var(D_1) + (1-p)^2var(D_2)$$ and I substituted the values with the given constants and I obtained the answer.
Now, I want to compute the same value for $var(Y)$ using the following formula:
$$var(Y) = E[Y^2]- E^2[Y]$$
I am asking myself how $E[Y^2]$ looks like. Here is what I've tried:
$$Y^2 = p^2D_1^2 + (1-p)^2D_2^2 + 2p(1-p)D_1D_2$$ Therefore I applied the $E$ operator and here is what I've got:
$$E[Y^2] = p^2E[D_1^2] + (1-p)^2E[D_2^2] + 2p(1-p)E[D_1]E[D_2]$$ because $E[D_1D_2] = E[D_1]E[D_2]$, due their independence.
But, when I substitute the values with constants, I got a different answer from the first computation for $var(Y)$. What did I do wrong?