You roll a fair six-sided die, and then you flip a fair coin the number of times shown by the die. Find the expected value and the variance of the number of heads obtained.
You can use indicator functions (the way we did when we found expected number of true propositions). Like: Let I_j takes value 1 if the jth toss is head and 0 otherwise. And then N, number of heads = I_1 + I_2 + I_3 + I_4 +I_5 + I_6
Then use linearity of expectation. And rest is just simple computing.
There is another computationally less involved way to do this problem:
Let X be the number of heads. Let N be the number on the dice.
E[X] = E[E[X|N]] = E[Np] = pE[N] = (1/2) (21/6) = 7/4
V[X] = E[V[X|N]] + V[E[X|N]] = E[Np(1-p)] + V[Np] = p(1-p)E[N] + (p^2)V[N] = 21/24 + 105/144 = 231/144 = 77/48