Similarity of two vectors

Take your time, follow the code and check your understanding.

The codeRAG fundamentals
a = [1, 0]
b = [0.6, 0.8]
print(sum(x * y for x, y in zip(a, b)))
Your answer4 min · no timer
What will the code print?

Show solution and explanation

For vectors normalised to length 1, the dot product equals cosine similarity. Here 1*0.6 + 0*0.8 = 0.6. Closer to 1 means more similar direction.

0.6