Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Suppose that you have a two-dimensional array (list of lists) of numeric values where each row of the array has the same number of elements.

Suppose that you have a two-dimensional array (list of lists) of numeric values where each row of the array has the same number of elements. For example, the following array has two rows of five elements:

t = [[8, 1, 6, 3, 5], [7, 0, 4, 9, 2]]

If you print the rows on top of one another then you get something that looks like a matrix:

8 1 6 3 5 7 0 4 9 2

In the module question3.py, write a function to_vector(t) that has a two-dimensional array t as a parameter and returns a list made up of elements of t taken column-wise; that is, the elements of the returned list are:

  • the elements of first column of t, followed by
  • the elements of second column of t, followed by
  • the elements of third column of t, and so on

For the array shown above the function should return the list:

[8, 7, 1, 0, 6, 4, 3, 9, 5, 2]

If t is an empty array then the function should return the empty list.

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

Data And Databases

Authors: Jeff Mapua

1st Edition

1978502257, 978-1978502253

More Books

Students also viewed these Databases questions

Question

What is the difference between Needs and GAP Analyses?

Answered: 1 week ago

Question

What are ERP suites? Are HCMSs part of ERPs?

Answered: 1 week ago