In the case of a Bernoulli random variable, $X$ can take on the values of $0$ and $1$ with probabilities $1-p$ and $p$ respectively. Therefore, the expectation of $X^2$ is given by:
\[E(X^2) = \sum_{x=0}^{1} x^2P(X=x) = 0^2(1-p) + 1^2p = p\]
Show more…