Return the cosine similarity of two equal-length vectors, rounded to six decimals: the dot product divided
by the product of the vectors' lengths (L2 norms). If either vector has length zero, return 0.0.
Implement cosine. Input: a: list[float], b: list[float]. Returns: float.
def cosine(a: list[float], b: list[float]) -> float:
return 0.0
Run executes the public tests. Submit grades against public and hidden tests.
Return the cosine similarity of two equal-length vectors, rounded to six decimals: the dot product divided
by the product of the vectors' lengths (L2 norms). If either vector has length zero, return 0.0.
Implement cosine. Input: a: list[float], b: list[float]. Returns: float.
def cosine(a: list[float], b: list[float]) -> float:
return 0.0
Run executes the public tests. Submit grades against public and hidden tests.