$f:X\longrightarrow\mathbb{R}$ is continuous iff $\{x\in X:f(x)\geq\alpha\}$ and $\{x\in X:f(x)\leq\alpha\}$ are closed $\forall\alpha\in\mathbb{R}$
$(\implies)$ Observe that $\{x|f(x)\geq\alpha\}=f^{-1}([\alpha,\infty[)$. Similarly the second set is $f^{-1}(]\infty,\alpha])$. If $f$ is continuous then, as these sets are the preimages of closed sets of the real line, they are closed.
$(\impliedby)$ Let $\forall\alpha:f^{-1}([\alpha,\infty[),f^{-1}(]\infty,\alpha])$ be closed. It suffices to show that the preimage of an open interval under $f$ is open (since open intervals generate the topology of the real line). Let $O:=]a,b[\subseteq\mathbb{R}$. Then $O=\mathbb{R}\setminus(]\infty,a]\cup[b,\infty[)$.
$\implies f^{-1}(O)=(f^{-1}(]\infty,a]\cup[b,\infty[))^c=(f^{-1}(]\infty,a])\cup f^{-1}([b,\infty[))^c$. Union of two closed sets are closed, hence the result follows.
Note: Admittedly this is a topological proof, so to speak. If you need an analytical argument let me know.