TITLE: If $\operatorname{var}(X) =0$ then $p( X = E (X)) = 1.$
QUESTION [6 upvotes]: Let $X$ be a random variable.
Then $\operatorname{var}(X) =0$ implies $p( X = E (X)) = 1.$
Actually i need both directions. But i was able to show that  $p( X = E (X)) = 1$ implies $\operatorname{var}(X) =0.$ So all i need is the other direction. 
I think we have to use the definition of the variance and set the $\operatorname{var}(X) = 0.$ But why is $p(X = E(X)) = 1$?

REPLY [4 votes]: Shorter:
$(X-\Bbb{E}[X])^2 \geq 0$ by definition. So it follows directly from $\Bbb{E}[(X-\Bbb{E}[X])^2] = \operatorname{Var}(X) = 0$, that $(X-\Bbb{E}[X])^2 = 0$ almost surely. We conclude $X-\Bbb{E}[X] = 0$ almost surely. That is what you wanted to show.