Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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

More Books

Students also viewed these Databases questions