Skip to content

Commit 0f700d1

Browse files
committed
Scalar product (correction).
1 parent a72df73 commit 0f700d1

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

math_library.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
def scalar_product(vector1, vector2):
2+
if len(vector1) != len(vector2):
3+
raise ValueError("Vectors must be of the same length")
4+
return sum(x * y for x, y in zip(vector1, vector2))

0 commit comments

Comments
 (0)