Cosine similarity
Your task
Implement cosine similarity between two equal-length numeric vectors from scratch. Cosine similarity is the dot product of the two vectors divided by the product of their L2 (Euclidean) norms. Both inputs are non-empty lists of numbers of the same length. If either vector has zero magnitude, return 0.0. Round the result to 6 decimal places.
Examples
cosine_similarity(a: list[float], b: list[float]) -> floatExample 1
Input
cosine_similarity([1, 0, 0], [1, 0, 0])Output
1