A map is continuous if and only if the restrictions are I want to find out if the following statement is true or false, and prove why:

Let $X$ be a topological space. Suppose $X=A \cup B$ and $f:X \rightarrow Y$ is a map whose restrictions to $A$ and $B$ are $f_A:A \rightarrow Y$ and $f_B:B \rightarrow Y$. Then $f$ is continuous if and only if $f_A$ and $f_B$ are continuous. 

I'm not really sure where to start with a proof on this. What's a good way to prove a map is continuous in this context?
 A: Use the definition : $f$ is continuous if and only if $f^{-1}(V)$ is open for any $V$ open set (and using the fact that the topology on a subset $T$ of $X$ is defined by all the $V\cap T$ where $V$ is a open set of $X$).
It is easy to verify that 
$$f_{|T}^{-1}(V)=\{T\cap f_{|T}^{-1}(V)\} $$
So, if $f$ is continuous, $f_{|A}$ and $f_{|B}$ are continuous.
Without further assumption on $A$ and $B$, the converse is false (cf. the other comment for a counter example).
A: Let $f(x) = 0$ if $x \neq 0$ and $f(0) = 1$. Then $f$ is obviously not continuous with respect to the usual topology on $\mathbb R$. Futher one can write $\mathbb R = A \cup B$ with $A = \mathbb R \setminus \{0\}$ and $B = \{0\}$. Though the restrictions $f_A$ and $f_B$ are continuous. Hence the assertion above doensn't hold :)
Nonetheless you can show that restrictions of continuous functions are indeed continuous again with the approach that Netchaiev gave.
A: It is not true as it stands, take any subset $A$ of the real line, standard topology, and consider the indicator function on $A$. This is continuous (constant) on the restriction to $A$ and its complement, respectively.
A: Continuity of restrictions $f_A:A\to Y$ and $f_B:B\to Y$ does not justify the conclusion that $f$ is continuous. 
The extra condition needed for that is that $A$ and $B$ have the so-called gluing property.
Let $\tau$ be the topology on $X$ and let $A$ and $B$ both be equipped with the induced subspace topology.
Then there is a topology $\tau'$ on $X=A\cup B$ prescribed by the rule: $$V\in\tau'\iff [V\cap A\text{ is open in }A]\wedge [V\cap B\text{ is open in }B]$$or equivalently by the rule:$$F^{\complement}\in\tau'\iff [F\cap A\text{ is closed in }A]\wedge [F\cap B\text{ is closed in }B]\tag1$$
Then evidently $\tau\subseteq\tau'$. 
In the special case that $\tau'$ is not properly finer than $\tau$ (so $\tau'=\tau$) the sets $A$ and $B$ have the gluing property.
It is the special case in which the following diagram - where all arrows denote inclusions - is a pushout square.
$$\begin{array}{ccc}
A\cap B & \longrightarrow & A\\
\downarrow &  & \downarrow\\
B & \longrightarrow & A\cup B
\end{array}$$
If $A$ and $B$ are both closed (or are both open) then $(1)$ makes clear that $A$ and $B$ have the gluing property.
A: If A and B are both open or closed, then f is continuoue.
Create an example for which f is not continuous.  
Set the problem up for an infinite number of sets all of which
are open or all of which are closed.  Show f is continuous
for one and give an example for the other for which f is not
continuous.
