Two vectors point somewhere in space. How far apart are their directions, in degrees?
The dot product already knows, you just have to unwrap it. Divide by both lengths to get the cosine of the angle, then undo the cosine:
Task: write angle_degrees(a, b) returning the angle in degrees, rounded to 4 decimal places.
a and b are vectors of the same length (3D in the tests, but the arithmetic doesn't care), and neither is all zeros.math.acos works in radians, so convert at the end with math.degrees.[-1, 1] before calling acos. Floating-point arithmetic can produce 1.0000000000000002 for two identical vectors, and acos raises a ValueError on anything past 1. One max(-1.0, min(1.0, c)) prevents it.0 and 180 degrees. arccos can't tell you which way around the angle goes, and in 3D there's no single sensible answer to that anyway.The three landmarks worth knowing by heart: same direction is 0°, perpendicular is 90°, and opposite is 180°. Dividing by the lengths is what makes this about direction alone — a vector and its own double give an angle of exactly zero.