Question: With using Python programming: Define a 3-dimensional vector class to handle a vector in cartesian coordinate (x,y,z). Please implement the constructor and allow the class

With using Python programming:

Define a 3-dimensional vector class to handle a vector in cartesian coordinate (x,y,z). Please implement the constructor and allow the class to record the x-y-z coordinate, and can be used in the later part of the template code. That is --- you should allow the template code to print out something like:

attributes of v1: 3.0 4.0 5.0 attributes of v2: 5.2 7.4 -2.5

class Vector3D(object): ### START YOUR CLASS IMPLEMENTATION HERE ###

def __init__(self): pass

#### END YOUR CLASS IMPLEMENTATION HERE ####

v1 = Vector3D(3.0,4.0,5.0) print('attributes of v1:', v1.x, v1.y, v1.z)

v2 = Vector3D(5.2,7.4,-2.5) print('attributes of v2:', v2.x, v2.y, v2.z)

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!