Home / Expert Answers / Computer Science / please-help-need-in-python-create-a-class-called-vector-the-class-vec-pa515

(Solved): PLEASE HELP NEED IN PYTHON!!!!!!!!!!!!!!!!!!!!!!!!!!! Create a class called Vector. The class Vec ...



Create a class called Vector. The class Vector must contain 3 instance variables
You class should have the following public m

PLEASE HELP NEED IN PYTHON!!!!!!!!!!!!!!!!!!!!!!!!!!!

Create a class called Vector. The class Vector must contain 3 instance variables You class should have the following public methods: 1. def _init__(self, xcoord, ycoord, zcoord) This is the constructor of your vector class. It should initialize 3 private instance variables, called \( \mathrm{x}, \mathrm{y}, \mathrm{z} \) with the values of the input variables, xcoord, ycoord, and zcoord respectively. 2. def add(self, v): This method should return a new Vector which is calculated by adding this vector-i.e. the vector which is doing the behaviour-to the vector passed to it as a parameter. 3. double def dotProduct(self, v): This method should compute the dot product of this vector with the vector given as parameter. Note that to compute the dot product of 2 vectors, you multiply each component and then add the sums. For example: \( (x 1, y 1, z 1) \cdot(x 2, y 2, z 2)= \) \( x 1 x 2+y 1 y 2+z 1 z 2 \) Then, test the following \[ \begin{array}{l} v 1=\operatorname{Vector}(1,1,1) \\ v 2=\operatorname{Vector}(2,3,1) \end{array} \] v1.add(v2) print(v1.dotProduct(v2))


We have an Answer from Expert

View Expert Answer

Expert Answer


Design the class Vector and implement the constructor, add method and dotProduct
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe