Question A2: Defining Vectors (9 points) Define class Vector for n-dimensional vectors as follows: Vector( l) : Creates a new vector with dimension…
Define class Vector for n-dimensional vectors as follows: Vector(l): Creates a new vector with dimension len(l) from list l of numbers; raises TypeError if l is not a list or not all of its elements are of type int or float. v.dim(): Returns the dimension (length) of the vector. v. __getitem__(i): Returns the i-th component of the vector, where components are indexed starting from 1; raises IndexError if i is less than 1 or greater than the […]