Solution (source code)

= Solution
{c}

The density is an even function on a symmetric interval, so the integrand $x f(x)$ is odd. Its <integral> vanishes:
$$
\boxed{\mathbb E[X]=\frac2\pi\int_{-\pi/2}^{\pi/2}x\cos^2x\,dx=0.}
$$