Let $X$ be a continuous random variable with density function
$$f(x)=\begin{cases} \frac{x}{2} & \text{if}\; 0 \leq x \leq 2& \\ \\ 0 &\text{otherwise}& \end{cases}$$
What is $E[|X-E[X]|]$?
I've tried to evaluate E(X). And wouldn't the answer be 0?
But instead the answer given is $\frac{32}{81}$
Let's evaluate $\mathbb{E}(X)$ step by step. By definition, if $X$ is a continuous RV with PDF $f(x)$ then $\mathbb{E}(X)=\int_\mathbb{R} x f(x) \mathrm{d}x$. In your case since $f(x)=0$ outside of the interval $[0,2]$ we have $$\mathbb{E}(X)=\int_0^2 x \cdot \frac{x}2 \mathrm{d}x=\frac12 \int_0^2 x^2 \mathrm{d}x$$ $$=\frac12 \cdot\frac13 x^3 |_0^2=\frac16 (8-0)=\frac86=\frac43\neq 0,$$ which is clearly non-zero. You should carefully check your integration, since this is but basic rules of integration—all that was used is the power rule $\int x^n \mathrm{d}x=\frac1{n+1} x^{n+1}$ and it is really not a matter of probability at this point once you know the definition of $\mathbb{E}(X)$, it's just routine calculus). Can you now compute $\int |x-4/3| \frac{x}2 \mathrm{d}x$? Note you will have to split it up based of the definition of absolute value and find the appropriate limits of integration.