Question: Write a Python function scale that takes two arguments. The first must be a number, the second can be either int, float, Vector, or Matrix.

Write a Python function scale that takes two arguments. The first must be a number, the second can be either int, float, Vector, or Matrix. It returns a new object of the same type as the second argument that is the scaling of the second argument

Example:

>>> scale(2, 3)

6

>>> scale(2, 3.14)

6.28

>>> scale(2, Vector([4,5]))

Vector(data=[8, 10])

>>> scale(2, Matrix(2,3,[1,3,2,7,5,8]))

Matrix(rows=2, cols=3, data=[2, 6, 4, 14, 10, 16])

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!