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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started