Continuity defined for rational and irrational numbers Let $h(x) = x$ for all rational numbers $x$ and $h(x) = 0$ for irrational numbers. I'm trying to show that $h$ is continuous at $x=0$ and at no any other point.
Defintion of continuity at $x_0$: $(\forall x)(\forall \varepsilon > 0)(\exists \delta > 0)$ such that $|x-x_0| < \delta \implies |h(x) - h(x_0)| < \varepsilon$.
For this part of the question I took $\delta = \epsilon$. Then $|x - 0| < \delta \implies |h(x)| < \varepsilon$ because if $x$ is rational, then $x < \varepsilon$ and if $x$ is irrational then $|x| < \varepsilon$. 
Defintion of discontinuity at $x_0$: $(\exists x)(\exists \varepsilon > 0)(\forall \delta > 0)$ such that $|x-x_0| < \delta \implies |h(x) - h(x_0)| \geq \varepsilon$.
I tried to divide the problem into two cases:
1) If $x_0$ is rational, then $|h(x) - h(x_0)| = |h(x) - x_0|$. Then pick $x$ to be a irrational number. Then I have $|h(x) - x_0| = |x_0|$. And take $\varepsilon = \frac{|x_0|}{2}$.
2) Now if $x_0$ is irrational $|h(x) - h(x_0)| = |h(x)|$. Now here is where I was unsure of myself: If I pick $x$ to be a rational number, then $|h(x)| = |x|$. I was not sure about choosing $\varepsilon$ so that $|x| \geq \varepsilon$. Would it be valid to take $\varepsilon = \frac{|x|}{2}$? (I mean $|x|$ here and not $|x_0|$)
Could I get some feedback? Thanks!
Edit
To finish off the last part, let $\varepsilon = \frac{|x_0|}{2}$. Now I want to choose an $x$ in the rational numbers. I also need to satisfy $x_0 - \delta < x$ (since $|x_0 - x| < \delta$) and $|x| \geq \frac{|x_0|}{2}$. So now I pick $x \in (|x_0|-\delta, |x_0|) \cap (\frac{|x_0|}{2}, |x_0|)$.
 A: 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$).
A: 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.
A: So you finished showing $f(x)$ is continuous at $x=0$, and $f(x)$ is discontinuous at rational numbers. For the last part, to prove $f(x)$ is not continuous at rational $x_0(x_0\neq 0)$, I provide a hint as follows.
For any $x_0\neq 0$, there exists $\delta>0$ such that if $|x-x_0|<\delta, |x|>\frac{|x_0|}{2}$, and thus you can still take $\epsilon=\frac{|x_0|}{2}$ and finish the proof by yourself.
