One of the problems of introducing students to topology is that the open set axioms are often taken as THE definition of a topology, when they are quite unintuitive, though extremely useful in the long run. I argue that the neighbourhood definition, while somewhat cumbersome, has the advantage of being closely related to ideas from analysis, and has a historical basis; it is of course as follows:
A neighbourhood topology on a set $X$ assigns to each element $x \in X$ a non empty set $\mathcal N(x)$ of subsets of $X $, called neighbourhoods of $x$, with the properties:
If $N$ is a neighbourhood of $x$ then $x \in N$.
If M is a neighbourhood of $x$ and $M \subseteq N \subseteq X$, then $N$ is a neighbourhood of $x$.
The intersection of two neighbourhoods of $x$ is a neigbourhood of $x$.
If $N$ is a neighbourhood of $x$, then $N$ contains a neighbourhood $M$ of $x$ such that $N$ is a neighbourhood of each point of $M$.
Then one says a function $f: X \to Y$ is continuous wrt neighbourhoods on $X$ and $Y$ if for each $x \in X$ and neighbourhood $N$ of $f(x)$ there is a neighbourhood $M$ of $x$ such that $f(M) \subseteq N$. The open set definition of continuity is then justified as being equivalent to this definition in terms of neighbourhoods.
One also says a set $U$ in $X$ is open if $U$ is a neighbourhood of all of its points.
THEN one can develop the open set axioms and show that one can recover the neighbourhoods.
Students should be aware that there are many approaches to the notion of topology, whose advantages should be compared. There should be no "take it or leave it" approach, but students should be encouraged to form a judgement, in terms of the character of the theory and its methods. And see which definition is appropriate in which cases.
June 14: The above approach is taken in my book Topology and Groupoids, in order to motivate the definition of open set.
November 17, 2016. Peter Freyd writes in the Introduction to his book Abelian Categories
"If topology were publicly defined as the study of families of sets closed under finite intersection and infinite unions a serious disservice would be perpetrated on embryonic students of topology. The mathematical correctness of such a definition reveals nothing about topology except that its basic axioms can be made quite simple. And with category theory we are confronted with the same pedagogical problem. ......
A better (albeit not perfect) description of topology is that it is the study of continuous maps; and category theory is likewise better described as the theory of functors. Both descriptions are logically inadmissible as initial definitions, but they more accurately reflect both the present and the historical motivations of the subjects."
I would also like to put in a reference to remarks of Bill Lawvere that the notion of space in mathematics is crucial for the representation of motion. This is illustrated in this lecture Out of line, particularly the section and video on Motion.
26 January, 2020
I would like to add another reference, to "Indiscrete thoughts" by G-C Rota. He contrasts a definition with a description (p.48). The book has many other important points to make!
2 May, 2020 I'll also mention that a topology can also be axiomatized in terms of the closure operation, as well as in terms of Int and of Ext. Students should be encouraged to think and evaluate, and not just accept an authoritarian viewpoint.
(there is a volume of Progress in Commutative Algebra 2, Closures, Finiteness and Factorization, with four editors, published by de Gruyter in 2012, 328 pages, and available online; the Preface has some good remarks on analogies in mathematics).
13 May, 2020 I should also add the notion of filter, and that link for more detail, to the ways of axiomatising topological spaces, and more.
Best Answer
The set $\left(0, 1\right] = \left(0, \frac32\right) \cap \Big((0,1] \cup (2,3)\Big)$ is an open set in the codomain $(0,1] \cup (2,3)$. We have
$$f^{-1}\Big(\left(0, 1\right]\Big) = \left(0, 1\right]$$
which is not an open set in $(0,2)$. Therefore $f$ is not continuous.