132k views
5 votes
# possibilities: vector*float or float*vector (scalar product) or vector*vector (dot product). # Get it to do just one of the product’s first, then use introspection to do both __eq__ # vector == vector. Takes 2 args: self and a vector. Returns True or False. magnitude # magnitude of the vector. Takes 1 arg, self. Returns a float unit # conversion to a unit vector. Takes 1 arg, self. Scales the vector by the inverse of # the magnitude (1/magnitude). No return value. Raises ValueError if magnitude is 0 # with message "Cannot convert zero vector to a unit vector". Write a main function that tests the functionality of all methods in your v

User Tadej Mali
by
4.9k points

1 Answer

7 votes

Answer:

Please see attachment for both the code and the output.

# possibilities: vector*float or float*vector (scalar product) or vector*vector (dot-example-1
# possibilities: vector*float or float*vector (scalar product) or vector*vector (dot-example-2
User Binarygiant
by
3.5k points