Write a function contains_all_zero_col (table) that returns True if a given input table contains one column...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function contains_all_zero_col (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]] >>> contains_all_zero_col (table) True : >>> table = [[0.0, 0.0, 1.0], [0.5, -1.0, 2.0], [0.0, 4.0, 5.3]] >>> contains_all_zero_col (table) False - Write a function sublist_of_sum (lst, x), that returns the first sublist of 1st that sums exactly to x. Otherwise, it should return None if no such sublist exists. Function header: sublist of sum (1st, x) Input: a list 1st with numeric elements and a number x. Output: the first (left-most) sublist that sums exactly to x or None if no such sublist exists. Examples: >>> sublist_of_sum ([ 1, 8, 5, 10], 9) [1, 8] >>> sublist_of_sum ([ -5, -2, 4, 11], 15) [4, 11] >>> sublist_of_sum ([3, 7, 2, 3], 12) [3, 7, 2] >>> sublist_of_sum ([5, 9, -1, 2], 9) [9] >>> sublist_of_sum ([5, 9, -1, 2], 7) None Write a function contains_all_zero_col (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]] >>> contains_all_zero_col (table) True : >>> table = [[0.0, 0.0, 1.0], [0.5, -1.0, 2.0], [0.0, 4.0, 5.3]] >>> contains_all_zero_col (table) False - Write a function sublist_of_sum (lst, x), that returns the first sublist of 1st that sums exactly to x. Otherwise, it should return None if no such sublist exists. Function header: sublist of sum (1st, x) Input: a list 1st with numeric elements and a number x. Output: the first (left-most) sublist that sums exactly to x or None if no such sublist exists. Examples: >>> sublist_of_sum ([ 1, 8, 5, 10], 9) [1, 8] >>> sublist_of_sum ([ -5, -2, 4, 11], 15) [4, 11] >>> sublist_of_sum ([3, 7, 2, 3], 12) [3, 7, 2] >>> sublist_of_sum ([5, 9, -1, 2], 9) [9] >>> sublist_of_sum ([5, 9, -1, 2], 7) None
Expert Answer:
Answer rating: 100% (QA)
1 def containsallzerocoltable rowslentable number of rows are the number of element... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
You borrowed $4,000 to finance your educational expenses at the beginning of your junior year of college at an interest rate of 9% compounded annually. You are required to pay off the loan with five...
-
Each part of this exercise contains events from Exercise 5.42. In each case, decide whether the events are mutually exclusive. In Exercise a. A and B b. B and C c. A, B, and C d. A, B, and D e. A, B,...
-
Consider the amino acid histidine: OH NH NH2 side chain a) What type of orbital are the lone pairs in for each nitrogen atom on the side chain? (2 points) b) Which nitrogen atom on the side chain do...
-
We-B-Busy, Inc. uses job costing and a predetermined overheadrate based onmachine hours (MH). The firm estimated that it would use $240,000of MOH and7,500 MH this year. Data for February:Job 1010 2...
-
On September 30, 2019, after one month of operation, the general ledger of Cross Timbers Company contained the accounts and balances shown below. INSTRUCTIONS 1. Prepare a partial worksheet with the...
-
Calculate the absorption cross section for the transition in exercise 4. Data From Exercise 4:- Calculate the transition element \(H_{1, f i}\) for the interaction of a hydrogenoid atom with a...
-
Lessee Company enters into a 6-year finance lease of non-specialized equipment with Lessor Company on January 1,2020 . Lessee has agreed to pay \(\$ 28,000\) annually beginning immediately on January...
-
Trevor Corporations balance sheet at December 31, 2013, is presented below. During 2014, the following transactions occurred. 1. Trevor paid $2,500 interest on the bonds on January 1, 2014. 2. Trevor...
-
Question 3. Question 4 . _ Questlon 3: Accounting for Income Tax (15 marks) Not yet answered 3.1 Explain the meaning of temporary differences as it relates to deferred tax Marked out of calculations...
-
1. Which process should VBB choose to produce?? 2. How much would VBP be willing to pay for the testing that is currently offered, for each batch?? 3. Would we be considered a perfect test, at twice...
-
Jackson Company acquires 100% of the stock of ClarkCorporation on January 1, 2020, for $4,100 cash. As of that dateClark has the following trial balance: Debit $ 500 600 900 CashAccounts receivable 2...
-
What is the purpose of a preliminary survey and how is it performed?
-
What questions must an auditor consider in determining what corrective action to propose?
-
Why does the operational auditor assess risk?
-
You are given the following simplified statement of financial position of the Hackin Company as at 30 June year 9. a Calculate the companys current ratio and liquidity ratio. b The following...
-
What general functions are usually applicable in an operational audit?
-
Each partner is personally and individually liable for all partnership liabilities except the industrial partner. T or F?
-
Refrigerant-134a enters an adiabatic compressor as saturated vapor at 120 kPa at a rate of 0.3 m3/min and exits at 1-MPa pressure. If the isentropic efficiency of the compressor is 80 percent,...
-
Consider the following two code fragments for counting spaces and newlines: // Version 1 while (cin.get(ch)) // quit on eof { if (ch == ' ') spaces++; if (ch == ' ') newlines++; } // Version 2 while...
-
Mat and Pat want to invite their friends to a party, much as they did in Programming Exercise 8 in Chapter 16, except now they want a program that uses files. They have asked you to write a program...
-
Write a code fragment that asks the user to enter a positive integer and then creates a dynamic array of that many ints. Do this by using new, then again using a vector object.
-
Question: Cruise.com operated a Web site selling cruise vacations. It sent unsolicited e-mail advertisements-dubbed "E-deals"-to prospective customers. Eleven of these "E-deals" went to...
-
Question: Jerry Falwell was a nationally known Baptist minister. You can read about him on falwell.com. You can read about his views on homosexuality at fallwell.com-a site critical of his views....
-
Question: Timothy Vemor bought used (but original) versions of AutoCAD software at garage and office sales. Each time he tried to sell them on eBay, AutoDesk (the company that produced the software)...
Study smarter with the SolutionInn App