For a quantum system in a Hilbert space $$\mathcal H_S$$, in a basis $$\left\lbrace \textbf{e}_j = \left|e_j\right>\right\rbrace$$ (using bra-ket notation, so the dual of $$\left|e_j\right>$$ can be written as $$\left< e_j\right| = \left|e_j\right>^\dagger$$), the state of a closed/isolated system (i.e. a 'pure state') can be written as $$\left|\psi\right> = \sum_j\alpha_j\left|e_j\right>$$, with normalisation condition $$\left<\psi|\psi\right> = 1$$. Common bases for a qubit include the 'computational' basis $$\left\lbrace \left|0\right>, \left|1\right>\right\rbrace$$, the X-basis $$\left\lbrace \left|+\right>, \left|-\right>\right\rbrace$$ where $$\left|\pm\right> = \frac{1}{\sqrt{2}}\left(\left|0\right>\pm\left|1\right>\right)$$ and the Y-basis $$\left\lbrace \frac{1}{\sqrt{2}}\left(\left|0\right>+i\left|1\right>\right), \frac{1}{\sqrt{2}}\left(\left|0\right>-i\left|1\right>\right)\right\rbrace$$. Upon measurement, the probability of obtaining the result $$\left|e_k\right>$$ is $$\mathbb P_k = \left|\left< e_k |\psi\right>\right|^2 = \left<\psi|P_k|\psi\right>$$ where $$P_k = \left| e_k\rangle\langle e_k\right|$$ is the 'projector' onto state $$\left| e_k\right>$$. More generally, for an operator $$A$$, the expectation value is $$\left< A\right> = \left<\psi|A|\psi\right>$$
When the system is instead open/mixed, the system is described by a density matrix $$\rho = \sum_{j, k}c_{j, k}\left| e_k\rangle\langle e_j\right|$$ and the expectation of $$A$$ becomes $$tr\left(\rho A\right)$$.