Solution (source code)

= Solution
{c}

Expand the square and use <linearity of expectation>, together with $\mathbb E[X]=\mu$ and $\mathbb E[1]=1$:
$$
\begin{aligned}
\operatorname{var}(X)&=\mathbb E[X^2-2\mu X+\mu^2]\\
&=\mathbb E[X^2]-2\mu\mathbb E[X]+\mu^2\\
&=\boxed{\mathbb E[X^2]-(\mathbb E[X])^2.}
\end{aligned}
$$
This proof applies whenever the second <moment> is finite, and does not require the <random variable> to be continuous.