Note that the real part is zero and hence $p(z)= \iota v(x,y)$ for some real function $v$. Now use the Cauchy-Riemann equations to show that $p$ is constant.
Solution: Let $p(z)$ be a polynomial which takes only imaginary values. We claim that $p$ is constant. Since $p$ takes only imaginary values, let $p(z) = \iota v(x,y)$. Since $p$ is analytic, it must satisfy the Cauchy-Riemann equations. Since, the real part is zero, then by Cauchy-Riemann equations, we must have
\begin{equation}\label{eq:03Jun2025-1}
v_x = 0 = v_y \implies v = k, \text{ a constant }.
\end{equation}
Thus, $p = \iota k$. Therefore, there does not exist any nonconstant polynomial which takes only imaginary values.
We can prove this is more generality. That is if $f$ is an entire function such that $\text{ Re } (f(z)) = 0$ for every $z\in \mathbb{C} $, then $f$ is constant. Since the real part of $f$ is zero, let $f(z) = \iota v(x,y)$. Define a function
\[
g(z) = e^{f(z)} = e^{\iota v(x,y)} = \cos v(x,y) + \iota \sin v(x,y).
\]
Since $f$ is an entire function and the exponential is also an entire function, the function $g$ entire. Also, note that $g$ is bounded. Thus, $g$ is an entire function which is bounded and hence by Liouville's theorem, $g$ is constant. This implies $f$ is also constant.