I do not get any output when I run the entire script.
class Vectors():
def __init__(self, coordinates):
try:
if not coordinates:
raise ValueError
self.coordinates = tuple(coordinates)
self.dimension = len(coordinates)
except ValueError:
print('The vector cannot be non-empty.')
except TypeError:
print('The object type is not iterable.')
def magnitude(self):
lst = [x**2 for x in self.coordinates]
return math.sqrt(sum(lst))
def dot_product(self, vector):
lst = [round(x*y, 3) for x,y in zip(self.coordinates, vector.coordinates)]
return sum(lst)
vector_v1 = Vectors([7.887, 4.138])
vector_w1 = Vectors([-8.802, 6.776])
vector_v1.dot_product(vector_w1)
vector_v1.magnitude()