A function on $X$ is continuous iff its restriction to each element of an open cover is continuous Problem

If $\{ B_\lambda : \lambda\in\Delta\}$  is any collection of open subsets of $X$ whose union is $X$, a function on $X$ is continuous iff its restriction to each $B_\lambda$ is continuous.

Context

*

*This is not true for general covers. For example, $X=(0,2)$ is the union of $(0,1)$ and $[1,2)$. The function $f=\chi_{(0,1)}$ is continuous on each element of the cover, but not continuous on $X$.

*In concrete cases like $X=(0,3)= (0,2)\cup (1,3)$ the statement seems clear: every convergent sequence in $X$ will eventually be either in $(0,2)$ or $(1,3)$. But in general, $X$ may be a topological space where we can't even use sequences to test convergence. How should one proceed then?

 A: Let $f:X\longrightarrow Y$ be a function between topological spaces. Recall that $f$ is continuous if and only if $f^{-1}(U)$ is open for every open set $U$ of $Y$. 
Let $\{U_i: i \in I\}$ be an open cover of $X$.
If $f$ is continuous, any of its restrictions is continuous. In particular its restrictions to each $U_i$.
Conversely, assume that each $f_i:=f_{|U_i}$ is continuous. Then take $U$ open in $Y$ and observe that
$$
f^{-1}(U)=\bigcup_{i\in I}f_i^{-1}(U).
$$
By assumption, each $f_i^{-1}(U)$ is open in $U_i$ for the topology induced by $X$ on $U_i$. That is, there exists $V_i$ open in $X$ such that $f_i^{-1}(U)=U_i\cap V_i$. Hence $f_i^{-1}(U)$ is open in $X$. It follows that $f^{-1}(U)$ is a union of open sets in $X$. So it is open. This holds for an arbitrary $U$ open in $Y$. So $f$ is continuous.
Note: this is false if your replace open cover by, say, infinite closed cover. The crucial point here is that the open sets of an open subset are open. It is true nevertheless for a finite closed cover. Just consider the preimages of closed sets. 
