Continuity defined for rational and irrational numbers

Solution 1:

No you can't take $\varepsilon = \frac{|x|}{2}$, since it is not constant.

But you can still take $\varepsilon = \frac{x_0}{2}$, because for any $\delta>0$ you will find $x$ such that $|x - x_0|< \delta$, but $h(x) > \varepsilon$ (for positive $x_0$ such $x$ is any rational number between $x_0$ and either $x_0 - \delta$ or $x_0 - \epsilon$, whichever is bigger; similarly for negative $x_0$).

Solution 2:

We have $$|h(x)|\leq |x|\to 0=h(0),\quad x\to0$$ so $h$ is continuous at $0$

For $x\neq 0$ take a sequence of rationals $(r_n)$ s.t. $r_n\to x$ and sequence of irrationals $(t_n)$ s.t. $t_n\to x$ and calculate the limit of $(h(r_n))$ and $(h(t_n))$ and conclude.