Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

def transform(data, num_rows, num_cols): Description: o Given a one-dimensional list of information data, return a new two-dimensional matrix of information where num_rows is the number

image text in transcribeddef transform(data, num_rows, num_cols): Description: o Given a one-dimensional list of information data, return a new two-dimensional matrix of information where num_rows is the number of rows in this matrix, and num_cols is the number of columns in this matrix. Assumptions: o The elements of data could be any basic type (float, int, bool, etc.) o If the desired matrix size is smaller than the number of elements in data, return an empty list. o If the size of the desired matrix is larger than the number of elements in data, fill in the gap with zeroes. Restrictions: o Remember, do not modify the original list. Examples: o # input and output sizes match transform([1,2,3,4,5,6], 2, 3) [[1,2,3],[4,5,6]] o # input and output sizes don't match (too big) transform([1,2,3,4,5,6], 3, 3) [[1,2,3],[4,5,6],[0,0,0]] o # input and output sizes don't match (too small) transform([1,2,3,4,5,6], 2, 2) []

def transform(data, num_rows, num_cols): Description: o Given a one-dimensional list of information data, return a new two-dimensional matrix of information where num_rows is the number of rows in this matrix, and num_cols is the number of columns in this matrix. Assumptions: o The elements of data could be any basic type (float, int, bool, etc.) o If the desired matrix size is smaller than the number of elements in data, return an empty list. If the size of the desired matrix is larger than the number of elements in data, fill in the gap with zeroes. Restrictions: o Remember, do not modify the original list. Examples: o # input and output sizes match transform([1,2,3,4,5,6], 2, 3) [[1,2,3], [4,5,6]] O # input and output sizes don't match (too big) transform((1,2,3,4,5,6], 3, 3) [[1,2,3], [4,5,6], [0,0,0]] # input and output sizes don't match (too small) transform([1,2,3,4,5,6], 2, 2) 0

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

Step: 3

blur-text-image

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

Answered: 1 week ago

Answered: 1 week ago