vector 1

vector

In mathematics, physics and engineering, a Euclidean vector
is a geometric object that has magnitude and direction. 
Vectors can be added to other vectors according to vector algebra

Examples include:

1.)displacement
2.)velocity
3.)position
4.)force
5.)torque

Here is what the above code is Doing:
1.)We are creating a class called Vector
2.)We are creating a constructor that takes in two arguments, x and y
3.)We are creating a method called __repr__ that returns a string representation of the vector
4.)We are creating a method called __add__ that takes in another vector as an argument and returns a new vector that is the sum of the two vectors
5.)We are creating a method called __mul__ that takes in a scalar and returns a new vector that is the product of the vector and the scalar

Similar Posts