The program has to be coded in python. No imported libs. 4. Write only a Function. Write a function named MaxCol that ta
Posted: Fri Apr 29, 2022 6:51 am
The program has to be coded in python. No imported libs.
4. Write only a Function. Write a function named MaxCol that
takes a nested list of data that
represents a matrix. An example parameter taken by this function
could be [[1, 2, 3],[4, 5, 6],[7, 8, 9]].
This represents the matrix
1 2 3
4 5 6
7 8 9
The function should be able to handle any sized matrix it is
given and the data in the matrix can be of
type float. The function should return which column has the maximum
sum and return the column
number (starting with 0 just like indexing lists) and the maximum
sum as a list. In the example above,
column 0 has a sum of 12, column 1 has a sum of 15, and column 2
has a sum of 18. The function
MaxCol would return [2, 18] in this case, where 2 is the col number
and 18 is the sum of col 2.
Example:
The function receives
[[10, 5.5], [3.1, -2.7], [2.8, 6.4]]
The function should return [0, 15.9] where 0 is the column number
and 15.9 is the sum of column 0.
You can build your own tests to test your function but please
comment them out when you submit your
file for this problem.
4. Write only a Function. Write a function named MaxCol that
takes a nested list of data that
represents a matrix. An example parameter taken by this function
could be [[1, 2, 3],[4, 5, 6],[7, 8, 9]].
This represents the matrix
1 2 3
4 5 6
7 8 9
The function should be able to handle any sized matrix it is
given and the data in the matrix can be of
type float. The function should return which column has the maximum
sum and return the column
number (starting with 0 just like indexing lists) and the maximum
sum as a list. In the example above,
column 0 has a sum of 12, column 1 has a sum of 15, and column 2
has a sum of 18. The function
MaxCol would return [2, 18] in this case, where 2 is the col number
and 18 is the sum of col 2.
Example:
The function receives
[[10, 5.5], [3.1, -2.7], [2.8, 6.4]]
The function should return [0, 15.9] where 0 is the column number
and 15.9 is the sum of column 0.
You can build your own tests to test your function but please
comment them out when you submit your
file for this problem.