$f:(0,1)\cup (1,2)\to \Bbb R$ and $f(x)=0$ if $x\in (0,1)$ otherwise $1$. Till today, I always thought that if the derivative of a function is $0$ at every point in the  domain, then the only functions possible for which this is true are constant functions. But, my teacher gave me the example $$f:(0,1)\cup (1,2)\to \Bbb R$$ with 
$$f(x) = \begin{cases}0&\mathrm{\ if\ } 0<x<1 \\ 1 &\mathrm{\ if\ }1<x<2\end{cases}$$
This function is not constant but has derivative $0$ everywhere in domain.I know it is pretty much possible because of the domain he chose, but what is special there in this domain which makes this happen. 
Can anybody give some other examples not of this form (which I gave above) having derivative $0$ without function being constant. 
 A: A differentiable function with zero derivative is constant on the connected components of its domain.
The function $\displaystyle f : \mathbb{R}-\mathbb{Z} \to \mathbb{R}$ given by $f(x) = \lfloor x \rfloor$ has derivative $0$ everywhere and it takes, not just 'more than one value', but in fact it takes infinitely many values $-$ you can't even bound it! But it is constant on all of the connected components of its domain; explicitly, $f|_{(n,n+1)}(x) = n$ for all $x \in (n,n+1)$.
In fact, any step-function will do, provided you remove the points at which it is not continuous from its domain.
A: Have you considered the function $f: \mathbb R\setminus\{0\} \to \mathbb R$ defined by $f(x):=\arctan(x)+\arctan(1/x)$?
Anyway this is not a real answer to your question. Indeed, the following theorem holds true: 

If $f\colon A\subset \mathbb R \to \mathbb R$ is differentiable at every point of $A$ with $f'(x) \equiv 0$ then $f$ is constant on every connected component of $A$. 

So the "key" to understand the examples lays in the topological properties of the domain. If the set $A$ is connected then every differentiable function $f :A\to \mathbb R$ with zero derivative (everywhere) is constant. 
Hope this helps. 
