Note: The \(x\) and \(y\) coordinates help form the bottom (if \(z\) is positive) or the top (if \(z\) is negative) of the rectangular prism.
We see \(\lvert {\color{NavyBlue}\overrightarrow{OQ}}\rvert = \sqrt{3^2+5^2} =\sqrt{34}\).
Thus, by the Pythagorean theorem
\[\lvert {\color{BrickRed}\overrightarrow{OP}}\rvert^2 = \lvert{\color{NavyBlue}\overrightarrow{OQ}}\rvert^2 + \lvert\overrightarrow{PQ}\rvert^2\]
Observe \(\lvert {\color{NavyBlue}\overrightarrow{OQ}}\rvert^2 = 3^2+5^2=34\) and \(\lvert \overrightarrow{PQ}\rvert^2=4^2=16\), then
\[\lvert {\color{BrickRed}\overrightarrow{OP}}\rvert = \sqrt{3^2+5^2+4^2} = \sqrt{50} =5\sqrt{2}\]
In general, if \(\overrightarrow{u}=(a,b,c)\), then \(\lvert \overrightarrow{u}\rvert = \sqrt{a^2+b^2+c^2}\).