Why is this function continuous, unlike the Dirichlet function? My teacher showed us this function and told us it was continuous at all non-$\mathbb{Q}$ points:
$$ f(x) = \begin{cases}
  x & \text{ if } x\in\mathbb{Q} \\\\
  0 & \text{ if }x\notin\mathbb{Q} \end{cases} $$
However, Wolfram MathWorld says the Dirichlet function, which is very similar, is discontinuous at all points. Why is one continuous and the other not?
 A: As other answers have Henning's answer has explained already, your teacher is wrong. However, my guess is that s/he was confusing your function with this related one:
$$
f(x) = \begin{cases}
0, &\text{ if $x$ is irrational},
\\\\
1/b, &\text{ if $x = a/b$ with $\gcd(a,b)=1$}.
\end{cases}
$$
This function does have the property that it is continuous at all irrational points, and discontinuous at the rationals. 
Source: Look at the "modified Dirichlet function" $D_M(x)$ in the Mathworld article on the Dirichlet function. 
Edit: It turns out that @lhf posted the same answer independently, but he links to the Wikipedia page of the function: click here. 
Terminology: I just learned1 that this function is usually called Thomae's function, and not the modified Dirichlet function. I have known this example for some time, but not by any specific name. Wikipedia lists a number of other interesting names as well: the Riemann function, the popcorn function, the Stars over Babylon, the raindrop function, and the ruler function.

1In the post what functions or classes of functions are Riemann non-integrable but Lebesgue integrable, Hans Lundmark's comment (under Jonas Meyer's answer) gives the name of the function and the wikipedia link. Thanks to Theo Buehler for sharing the post. 
A: Your teacher is wrong. Every neighborhood of any real number contains both rational and non-rational points, so the function is continuous at 0 only.
More specifically, let $\alpha$ be a positive irrational number (in particular $\alpha\ne0$, and the argument for negative irrationals is almost the same). Let's check whether $f$ is continuous at $\alpha$. For this to hold, then for every $\epsilon>0$ there must be a $\delta$ such that
$$ |x-\alpha|<\delta \Rightarrow |f(x)-f(\alpha)|<\epsilon $$
Since $f(\alpha)=0$, the right-hand side of this is equivalent to $|f(x)|<\epsilon$.
As I'm going to prove that $f$ is not continuous at $\alpha$, I have the right to select $\epsilon$, and then I must prove that there's no $\delta$ that works for it. I choose $\epsilon=\alpha/2$. Now, for every possible positive $\delta$, the interval $(\alpha, \alpha+\delta)$ is open and therefore contains at least one rational number, which we can call $R$. Then, setting $x=R$ we get $|R-\alpha|<\delta$ (by construction), but $|f(R)|=R>\alpha$ is certainly larger than $\epsilon$, which was $\alpha/2$. Thus, $\delta$ fails to work, as promised.
A: Perhaps your teacher meant Thomae's function, which is continuous at all irrational numbers and discontinuous at all rational numbers.
