Question
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 question2.py, write a function size(t) that has a two-dimensional array t as a parameter and returns a list of length 2 where the first element of the returned list is the number of rows in t and the second element is the number of columns in t.
For the array shown above the function should return the list:
[2, 5]
If t is an empty array then the function should return the list [0, 0].
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started