Var$(X) = \mathbb{E}((X - \mathbb{E}(X))^2) = \mathbb{E}(X^2) - \mathbb{E}(X)^2$ I have a question about something my teacher told us:

let $\mathbb{E}$(X) donate the expected value of a certain random variable $X$. 

Then Var$(X) = \mathbb{E}[(X - \mathbb{E}(X))^2] = \mathbb{E}(X^2) - \mathbb[{E}(X)]^2$. I can't understand why the last equation holds. Can you explain this to me?
It's a simple calculation. First,
$$
\mathbb{E}[(X-\mathbb{E}[X])^2] =
\mathbb{E}[X^2 + \mathbb{E}[X]^2 - 2X\mathbb{E}[X]].
$$
Linearity of expectation implies
$$
\mathbb{E}[X^2 + \mathbb{E}[X]^2 - 2X\mathbb{E}[X]] =
\mathbb{E}[X^2] + \mathbb{E}[X]^2 - 2\mathbb{E}[X]^2 = \mathbb{E}[X^2] - \mathbb{E}[X]^2,
$$
using the fact that $\mathbb{E}[X]$ is a constant.
Expand $\mathbb{E}[(X−\mathbb{E}(X))^2]$ and use linearity of $\mathbb{E}$.