In quantum mechanics, why is $\langle T\rangle=\frac{\langle p^2 \rangle}{2m}$ rather than $\langle T\rangle=\frac{\langle p \rangle^2}{2m}$? I'm a newbie reading quantum mechanics from "Inroduction to Quantum Meachanics" by Griffiths and in the early pages of the book the author defines: 
$$\langle x\rangle =\int_{-\infty}^{\infty} x|\Psi(x,t)|\,dx = \int_{-\infty}^{\infty} \Psi^* (x)\Psi \,dx,$$
$$\langle v\rangle = \frac{d}{dt}\left(\langle x\rangle\right)= -\frac{i\hbar}{m}\int_{-\infty}^{\infty} \Psi^*\frac{\partial\Psi}{\partial x} \,dx,$$
$$\langle p\rangle = m\langle v\rangle= -i\hbar\int_{-\infty}^{\infty} \Psi^*\frac{\partial\Psi}{\partial x} \,dx,$$
so to me the author seems to be working  out with expectations, which made perfect sense to me. I then googled the expression for kinetic energy and I was expecting to find out that: 
$$\langle T\rangle=\frac{\langle p \rangle^2}{2m},$$
but instead, it seems that
$$\langle T\rangle=\frac{\langle p^2 \rangle}{2m}.$$
Why is this? I don't understand what happened in the case of kinetic energy. Why isn't the author now working with expected momentum in the case of expected kinetic energy? Can you perhaps show me a derivation of $\langle T\rangle $ and more importantly, explanation on why it is done like that? In the book, the author says that generally: 
$$\langle Q(x, p)\rangle = \int \Psi^*Q(x, \frac{\hbar}{i}\frac{\partial}{\partial x})\Psi\,dx,$$
with advising that every $p$ should be replaced with $\frac{\hbar}{i}\frac{\partial}{\partial x}$ when calculating the expectation of interest. The why-part for this was however a bit non-existing.
 A: If you think about it, this really doesn't come down to QM and just depends on how you take averages. QM only comes into play if you actually want to calculate those averages given the state vector of the system.
We know that $T=\frac{p^2}{2m}$, so the average of this is then
$$\langle T\rangle=\left\langle\frac{p^2}{2m}\right\rangle=\frac{\langle p^2\rangle}{2m}$$
Since, in general, $\langle p^2\rangle\neq\langle p \rangle^2$, this is where we end up.
If you want to find this value using the position basis, then we invoke QM:
$$\langle T\rangle=-\frac{\hbar^2}{2m}\int\Psi^*\frac{\partial^2}{\partial x^2}\Psi\ dx$$
This is because in the position basis, the $P^2$ operator is $-\hbar^2\frac{\partial^2}{\partial x^2}$.
A: 
Why is this?

For concreteness, let's look at a specific example for which $\langle T \rangle \ne \frac{\langle P \rangle^2}{2m}$
Consider the case that we have a particle with state vector (working in 1D for simplicity)
$$|\psi\rangle = \frac{1}{\sqrt{2}}\left(|+p\rangle + |-p\rangle\right)$$
where $p \ne 0$ and $P\,|\pm p\rangle = \pm p\,|\pm p\rangle$ (these are eigenkets of the momentum operator).
Clearly, the expectation value of momentum is
$$\langle P\rangle = \langle\psi|P|\psi\rangle = \frac{1}{2}\left(+p -p\right) = 0$$
This is because the momentum measurement has equal chance of yielding $+p$ and $-p$.
However, a kinetic energy measurement measurement can only yield
$$T = \frac{(\pm p)^2}{2m} = \frac{p^2}{2m}$$
and so
$$\langle T \rangle = \frac{p^2}{2m} \ne \frac{\langle P \rangle^2}{2m} = 0$$
