$f:\mathbb R\to\mathbb R$ continuous function. Which of the following sets can not be image of $(0,1]$ under $f$?
Solution 1:
If $f\colon\mathbb R\to\mathbb R$ is continuous, then the image of any compact set is compact. Especially, the image of $[0,1]$ is a compact set $C$. Then the image of $(0,1]$ is either $C$ or $C\setminus\{y\}$ for $x=f(0)$. The set $(0,1)$ is not of this form, hence cannot be the image of $(0,1]$.
For A, C, D one readily finds specific functions: $f(x)=0$, $f(x)=1-x$, $f(x)=|2x-1|$.
Solution 2:
One can easily find continuous functions with image such as in A,C or D, so if only one option is correct, it must be B.
To prove that B is impossible, you can argue as follows. Find, in the preimage, sequences $x_n$ and $y_n$ so that $f(x_n)\to 1$ and $f(y_n)\to 0$. Neither $1$ nor $0$ is in the image, so neither $x_n$ nor $y_n$ contains a subsequence convergent in $(0,1]$. But in $(0,1]$ the only chance for having a sequence that doesn't contain a convergent subsequence in $(0,1]$ is a sequence converging to $0$ (in $\mathbb{R}$). So, $x_n\to 0$ and $y_n\to 0$, hence $0=\lim f(x_n)=\lim f(y_n)=1$ which is a contradiction.
David Mitra offers a simpler argument in the comments above.
However, $(0,1)$ is a continuous image of $(0,1]$; for example $f(x)=(1-x)(\frac{1}{2}\sin(\frac{1}{x}))+\frac{1}{2}$ maps $(0,1]$ continuousy onto $(0,1)$. (But $f$ can not be continuously extended to $\mathbb{R}\to\mathbb{R}$)