Let $(X, T)$ be the subspace of $\mathbb R$ given by $X = [0,1]\cup [2,4]$. Define $f: (X,T) \to \mathbb R$ by $$f(x)= \begin{cases}1 & x \in [0,1] \\ 2 & x \in [2,4]\end{cases}$$ Show that $f$ is continuous.
Let $A= \{1\} \subset \mathbb R$ then clearly $A$ is closed in $\mathbb R$ with the usual topology. Now $f^{-1}(A)= [0,1]$. I need to show that $[0,1]$ is closed in $X$ with the relative topology on $X$.
Similarly let $B= \{2\} \subset \mathbb R$ then $B$ is closed in $\mathbb R$ with the usual topology. Now $f^{-1}(B)= [2,4]$. I need to show that $[2,4]$ is closed in $X$ with the relative topology on $X$.
This then shows that the preimage of closed sets under $f$ is closed, and hence $f$ is continuous.
I am, however, not sure how to show that $[0,1]$ and $[0,2]$ are closed in the relative topology of $X$.