Question: please help with this python program!!! URGENT Consider the following program and its output: Output : The program above uses the class Vector which you

please help with this python program!!! URGENT

Consider the following program and its output:

please help with this python program!!! URGENT Consider the following program and

Output:

its output: Output: The program above uses the class Vector which you

The program above uses the class Vector which you need to implement in the file vector.py. By inspecting the program and its output, you should be able to find out what attributes and functions are needed in the class Vector in order for the program to run and produce correct output.

need to implement in the file vector.py. By inspecting the program and

Note that vector.py should only contain an implementation of the class Vector.

from vector import Vector def test_print(vector): print("Vector: {}".format(vector)) def test_dimension(vector): print("Vector dimension: {}".Format(len(vector))) def test_length(vector): print("Vector length: {:.2f}".format(vector.length())) def test_addition(vectori, vector2): print("Vector1 + Vector2: {}".format(vector1 + vector2)) def test_scaling(vector, scalar): vector.scaling (scalar) print("Scaling vector by {}: {}".Format(scalar, vector)) # Main program starts here v1 Vector([2,4]) v2 = Vector([3,-4]) test_print(v1) test_print(v2) test_length(v1) test_length(v2) test_dimension(v1) test_addition(v1,v2) test_scaling(v1, 2) print() v1 = Vector([3,5,-2]) V2 Vector([2,-3,4]) test_print(v1) test_print(v2) test_length(v1) test_length(v2) test_dimension(v1) test_addition(v1,v2) test_scaling (v2, 3) Vector: [2, 4] Vector: [3, -4] Vector length: 4.47 Vector length: 5.00 Vector dimension: 2 : Vector1 + Vector2: [5, 0] Scaling vector by 2: [4, 8] Vector: [3, 5, -2] Vector: [2, -3, 4] Vector length: 6.16 Vector length: 5.39 Vector dimension: 3 : Vector1 + Vector2: [5, 2, 2] Scaling vector by 3: [6, -9, 12] The following holds for vectors: The length of an n-dimensional vector x=(X1, X2, ..., ,xn) is: Vx1 + x + ...x The addition of two n-dimensional vektors, x = (X1, X2, ..., X.) and y = (y1, Y2, ..., yn) is: (x1+ y1, X2+ y2, ..., Xn+yn) The scaling of an n-dimensional vector x = (x1, X2, ..., Xn) with a scalar t is: (x *t, x2*t, ..., Xn*t)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!