For the coordinates
\begin{align}
i&=1.0,\\ j&=0.0,\\ k&=0.17364817766693033,
\end{align}
consider the triangle with vertices
$(0,0,0),$ $(1,0,0),$ $(1,0,0.17364817766693033)$.
This is a right triangle with right angle at $(1,0,0).$
The other two vertices are the origin and your chosen point $(i,j,k).$
In this triangle, the leg opposite the origin has length $0.17364817766693033$ and the leg adjacent to the origin has length $1,$ so the ratio of those two legs,
$0.17364817766693033/1 = 0.17364817766693033,$
is the tangent of the angle at the origin. That angle is
$\arctan(0.17364817766693033) \approx 0.17193371309896594$ (in radians),
which is approximately $9.8510761165839062$ degrees.
Your program is giving the correct output.
You may have been thinking that by setting $k$ to the sine of $10$ degrees you should get a $10$ degree elevation. But the sine is the ratio of the opposite side of the triangle to the hypotenuse, that is, the ratio of $k$ to the magnitude $\sqrt{i^2+j^2+k^2}$. If you want to use $k=0.17364817766693033$ to get an elevation of $10$ degrees you need to ensure that $\sqrt{i^2+j^2+k^2} = 1,$
not that $i = 1.$
You can do this by setting $i$ to the cosine of $10$ degrees,
or you can set $i$ to $1$ but set $k$ to the tangent of $10$ degrees.
Best Answer
Both of the diagrams above represent spherical coordinate systems. Both have an azimuthal angle (the one that goes around the z axis) and a polar angle. Your question is why the polar angle is sometimes measured down from the zenith or else up or down from the xy plane. Both are perfectly valid, and one is not easier than the other. But is one more natural?
The answer depends on what you are using the spherical coordinates for. From a pure mathematician's point of view, the spherical coordinate system is a 3D version of the polar coordinate system, and measuring the polar angle from zenith makes sense. Here, the angle ranges from 0 to 2π.
However, if you are working with geospatial or astronomical data where the xy plane is the reference, it makes much more sense to measure from there. For example, when you think about latitude and longitude coordinates on the Earth, the equator is latitude 0°, not 90° (if measured from the North Pole). It would be a nightmare to have to constantly convert polar angles back and forth from a range of [-π/2,π/2] to [0,π]. Astronomers also use this to define multiple reference planes, e.g. your local horizon, the Solar System ecliptic. This allows us to measure the angles from a specific reference rather than what is essentially an arbitrary point on the sky. When I try to find a star at a declination of 5°, it's far easier to find the horizon and look up a little than find a point high in the night sky with no reference and look down 85° (or constantly be subtracting a value from 90!).
Either way you are still working in a spherical coordinate system and the maths only differ slightly since your polar angle range is different, but the selection of the polar angle reference can make conceptualizing coordinates much easier.