Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems For Advanced Applications 9th International Conference Dasfaa 2004 Jeju Island Korea March 2004 Proceedings Lncs 2973

Authors: YoonJoon Lee ,Jianzhong Li ,Kyu-Young Whang

2004th Edition

3540210474, 978-3540210474

More Books

Students also viewed these Databases questions

Question

What are signs of abnormal health in an animal?

Answered: 1 week ago