Note that

$$
|0\rangle\langle 1| = \begin{pmatrix} 1 \\ 0 \end{pmatrix} \begin{pmatrix} 0 & 1 \end{pmatrix}= \begin{pmatrix} 0 & 1 \\ 0 & 0 \end{pmatrix}
$$
and similarly

$$
|1\rangle\langle 0| = \begin{pmatrix} 0 \\ 1 \end{pmatrix} \begin{pmatrix} 1 & 0 \end{pmatrix}= \begin{pmatrix} 0 & 0 \\ 1 & 0 \end{pmatrix}
$$
and therefore
$$ X = |0\rangle\langle 1| + |1\rangle\langle 0| = \begin{pmatrix} 0 & 1 \\ 1 & 0 \end{pmatrix} $$

Thus you can see that $X|0\rangle = |1\rangle$ and $X|1\rangle = |0\rangle$. So giving the input is the state $|0\rangle$ then the output is the state $|1\rangle$ and vice versa.

A related answer.

– Davit Khachatryan – 2020-10-15T18:12:35.190