Let $f:X\to X $ be continuous. Does $f $ have a fixed point when $X=[0,1)$ or $X=(0,1) $? 
Let $f:X\to X $ be continuous. Show that if $X=[0,1] $, $f $ has a
  fixed point(i.e. there exists  $x$ such that $f (x)=x$). What happens
  if $X $ equals  $[0,1) $ or $(0,1) $?

First part of the question is an immediate consequence of intermediate value theorem(for a proof, see here). I think $f (x)=x^2$ is a counterexample when $X=(0,1) $, since $x^2\lt x $ for all $x\in (0,1) $. But to be honest, I don't understand what causes breakdown of the fixed point theorem on $(0,1)$, since IVT only requires connectedness of domain. Is this related to the non-compactness of $(0,1)$?
Also I can't think of any counterexample for the case $X=[0,1)$(assuming fixed point is somehow related to compactness).
Any help is appreciated. 
Thank you. 
 A: The compactness is not really used in proving the FPP for $[0,1]$. We do use both endpoints (we use $f(0) >0$ and $f(1) <1$ when $f$ has no fixpoint in $\{0,1\}$ which then triggers the IVT). You could say that compactness forces these endpoints to be in your set.. (compact and connected in $\mathbb{R}$ means homeomorphic to $[0,1]$).
So to find a counterexample, look for functions on $[0,1]$ with a unique fixed point that is either $0$ or $1$. Then removing that point makes a counterexample. $f(x) = \frac{1}{2}x$ is an easy one for $X=(0,1]$ e.g. 
A: $$f:[0,1) \to [0,1), x \mapsto  \frac x2 + \frac12$$
$$f:(0,1) \to (0,1), x \mapsto  \frac x2 + \frac12$$
If $x = f(x)$, then $x = 1$ which is not in the domain of $f$.  
$$f:(0,1] \to (0,1], x \mapsto \frac x2$$ also has no fixed points. 
A: The IVT is not the only ingredient here. The way the theorem works is by setting up this square:

where the line in the middle is $y = x$. A function from $[0, 1]$ to $[0, 1]$ that intersects this line will have a fixed point at the point of intersection.
The IVT kicks in when we have a function whose graph enters the top triangle and the bottom triangle at various points, e.g.

The fact is, by the IVT, the function has to cut the line somewhere, i.e. it must have a fixed point.
But, this makes an assumption! The function may only exist in one triangle or the other, but not in both. That is, why can we not have $f(x) > x$ for all $x$ or $f(x) < x$ for all $x$?

The picture above illustrates it. Due to the function having a full domain of $[0, 1]$, there's a squeeze happening. The green function is about as close as we can have to a function satisfying $f(x) > x$. Similarly, the red function attempts to have $f(x) < x$. But, both are pinched towards the diagonal line. The green function must have $f(1) = 1$, and the red function must have $f(0) = 0$.
This illustrates the necessity of defining all the way to $0$ and $1$. Removing either of these points means that the functions are not squeezed to a fixed point (we'd only ensure that $f(x)$ and $x$ become arbitrarily close).
