Question: python 1.Write a function column_contains_all_zeros(table) that returns True if a given input table contains one column with all elements equal to 0; and otherwise returns
python
1.Write a function column_contains_all_zeros(table) that returns True if a given input table contains one column with all elements equal to 0; and otherwise returns False.
Input: table table with numeric elements
Output: True if one column in table has all elements equal to 0; otherwise False
For example:
>>> table = [[0, 0, 1],
... [-2, 0, 3],
... [1, 0, -4]]
>>> column_contains_all_zeros(table)
True
>>> table = [[0.0, 0.0, 1.0],
... [0.5, -1.0, 2.0],
... [0.0, -4.0, 5.3]]
>>> column_contains_all_zeros(table)
False
2. Write a function left_sublist_sum(lst, m), that returns the first sublist of lst that sums exactly to m. Otherwise, it should return None if no such sublist exists.
Function header: left_sublist_sum(lst, m)
Input: a list lst with numeric elements and a number m.
Output: the first (left-most) sublist that sums exactly to m or None if no such sublist exists.
Examples:
>>> left_sublist_sum([ 1, 8, 5, 10], 9)
[1, 8]
>>> left_sublist_sum([ -5, -2, 4, 11], 15)
[4, 11]
>>> left_sublist_sum([3, 7, 2, 3], 12)
[3, 7, 2]
>>> left_sublist_sum([5, 9, -1, 2], 9)
[9]
>>> left_sublist_sum([5, 9, -1, 2], 7)
None
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
