Question: Problem 3 . Recall that the Vector data type represents a vector and supports the following API: 2 vector.Vector Vector ( a ) constructs a
Problem Recall that the Vector data type represents a vector and supports the following API:
vector.Vector
Vectora constructs a new vector v with Cartesian coordinates taken from the list a
vi returns the ith coordinate of v
v w returnsthesumofv andw
v w returns the difference of v and w
vscalealpha returns the scalar product of float alpha and v
vdotw returns the dot product of v and w
vdirection returns the unit vector in the same direction as v
absv returns the magnitude of v
lenv returns the dimensions of v
strv returns a string representation of v
Now suppose you have a dimensional vector v
a What is the syntax for creating a Vector object v that represents the vector v
A v Vector
B v
C v Vector.init
D v Vector
E v Vector.init
b What is the syntax for computing the dot product of the vectors v and v
A vdotVectorscalev
B vdot v
C VectordotVectorscalev
D Vectordotv v
E vdotvscale
c What is the dot product of the vectors v and v d What does the code absv translate to internally?
A vabsself
B vabs
C absself v
D vabs
E selfabsv
e What does absv return?
f Suppose x and y are two Vector objects. What does the code x y translate to internally?
A Vectoraddy x
B Vectoraddx y
C xaddy
D addx y
E yaddx
g What does lenv return?
h What does the code strv translate to internally?
A vstrself
B vstr
C selfstrv
D vstr
E strself v
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
