Vektorgrundgerüst

This commit is contained in:
2020-11-03 07:01:14 +01:00
commit 01d5aa7cb6

21
vector.py Normal file
View File

@@ -0,0 +1,21 @@
class Vector(object):
def __init__(self, coordinates):
try:
if not coordinates:
raise ValueError
self.coordinates = tuple(coordinates)
self.dimension = len(coordinates)
except ValueError:
raise ValueError('The coordinates must be nonempty')
except TypeError:
raise TypeError('The coordinates must be an iterable')
def __str__(self):
return 'Vector: {}'.format(self.coordinates)
def __eq__(self, v):
return self.coordinates == v.coordinates