Dot Product calculator
Dot Product calculator
vector_1
vector_2
Now we need to validate the code
# Value validation
vector_1_separated = vector_1.split(',')
vector_2_separated = vector_2.split(',')
if len(vector_1_separated) != len(vector_2_separated):
raise Exception('Vectors have different lengths.')
vector_1_floats = list(map(lambda num: float(num), vector_1_separated))
vector_2_floats = list(map(lambda num: float(num), vector_2_separated))
product = 0
for i, num in enumerate(vector_1_floats):
print(num, i)
product += num * list(vector_2_floats)[i]
print(f"Dot product of the vectors is {product}!")