3. A number $x$ is randomly chosen in the interval $[-1,1]$. Then the probability that the value of $\cos \frac{\pi x}{2}$ lies between 0 and $\frac{1}{2}$ is
(A) $\frac{2}{3}$
(B) $\frac{2}{\pi}$
(C) $\frac{1}{2}$
(D) $\frac{1}{3}$
3. D.

From $\cos \frac{\pi x}{2}=\frac{1}{2}$, we get $x= \pm \frac{2}{3}$.
From the graph of the function $y=\cos \frac{\pi x}{2}$, we know that the values of $x$ for which $\cos \frac{\pi x}{2}$ lies between 0 and $\frac{1}{2}$ fall within $\left[-1,-\frac{2}{3}\right]$ and $\left[\frac{2}{3}, 1\right]$.
Thus, the required probability is $P=\frac{2 \times \frac{1}{3}}{2}=\frac{1}{3}$.