Real polynomials with rational images for rational inputs and irrational images for irrational inputs. So the question is as follows, find all real polynomials, such as that $P(\mathbb{Q})$ $\subseteq \mathbb{Q}$ and $P(\mathbb{R} \setminus \mathbb{Q} ) \subseteq \mathbb{R} \setminus \mathbb{Q} $.
Rational polynomials of degree 1 verify this property, going beyond this becomes extremely complicated, since one cannot simply determine whether the sum of two irrationals is irrational.
It is also clear that all the real roots of this polynomial (if there exists any) are rational.
So how can I characterize such polynomials?
 A: Let $n=\deg P$ and assume $n\ge 2$.
Pick $n+1$ rational points $(x_i,P(x_i))$ and let $\tilde P(X)$ be the unique interpolating polynomial of degree $\le n$ through these points. By the formulae for interpolation, $\tilde P(X)\in\Bbb Q[X]$. And as $P(X)-\tilde P(X)$ has more than $n$ zeroes, we have $P(X)=\tilde P(X)$, i.e., $$P(X)\in\Bbb Q[X].$$
If $a,b$ are non-zero integers, then  $aP(\frac Xb)$ also has the special property. By choosing $a,b$ wisely, we can achieve that
$$\tag1 P(X)=X^n+a_{n-1}X^{n-1}+\cdots + a_1X+a_0\in\Bbb Z[X].$$
Namely, first multiply away the denominators, then divide the argument by the leading coefficient and multiply by the $(n-1)$st power of that coefficient to cancel the newly created denominators.
For $m\gg0$, $P(X)=m$ has exactly one solution $\xi_m$ in the positive reals.
By the special property, $\xi_m$ is rational, and by the rational root theorem, $\xi_m\in \Bbb N$.
By the Mean Value Theorem, there must exist a real number $\eta_m$ between $\xi_m$ and $\xi_{m+1}$ with $$|P'(\eta_m)|=\left|\frac{P(\xi_{m+1})-P(\xi_m)}{\xi_{m+1}-\xi_m}\right|=\frac1{|\xi_{m+1}-\xi_m|}\le 1.$$
Clearly, $\xi_m\to\infty$ and then also $\eta_m\to\infty$.
But for non-constant polynomial $P'$, the set $\{\,x\in\Bbb R: |P'(x)|\le 1\,\}$ is bounded - contradiction.
