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...
-
A house is cooled by an electric heat pump using the outside as the high-temperature reservoir. For several different summer outdoor temperatures, estimate the percent savings in electricity if the...
-
Hudson Company uses a job-order costing system. The following transactions took place last year: a. Raw materials were requisitioned for use in production, $38,000 (85% direct and 15% indirect). b....
-
In a random sample of 600 cars making a right turn at a certain intersection, 157 pulled into the wrong lane. Test the null hypothesis that actually \(30 \%\) of all drivers make this mistake at the...
-
In Eastwood Co., capital balances are Irey $40,000 and Pedigo $50,000. The partners share income equally. Vernon is admitted to the firm with a 45% interest by an investment of cash of $58,000....
-
A sample of 0.20 moles of diatomic perfect gas at 320 K undergoes an isothermal expansion from 2 to 8 . Make a P V diagram with the appropriate units. Calculate the work done by the gas during the...
-
Each year, a shoe manufacturing company faces demands (which must be met on time) for pairs of shoes as shown in the file S13_40.xlsx. Employees work three consecutive quarters and then receive one...
-
Answer the following questions either true or false. If any part of a statement is false, your answer should be false. Only if the entire statement is true, should you answer true. Unless you are...
-
Consider the following logic function: X=A (B+C)+C B 1. (10 pts) First implement this logic using a CMOS circuit by crafting the pulldown network to match the logic expression and utilize a follow-on...
-
Prepare a 0.15% (w/v) solution of haemoglobin in 10 mM HCl pH2. Dilute to 0.03, 0.05, 0.07% and 0.09% in 10 mM HCl pH 2. 2. Prepare a calibration curve of haemoglobin in 10mM HCl pH 2 at 372 nm...
-
What is a business plan? Why do companies prepare business plan? Have you ever created or read about a business plan prior to this course? Include references.
-
Business plans guide business decisions and actions. Have you been involved in a business planning process? Please discuss what you see as your strengths as weaknesses in the business planning...
-
How would you expect the price elasticity of demand for health care to vary with health status? Would the demand for health care increase or decrease with an improvement in educational attainment in...
-
Find the volume and total area of the largest cube of wood that can be cut from a log of circular cross section whose radius is 12.7 inches. See figure. 12.7" D
-
What is the back work ratio? What are typical back work ratio values for gas-turbine engines?
-
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.
-
Consider a stochastic process such that the underlying security \(S\) follows the model: \[d S_{t}=\mu S_{t} d t+\sigma_{t} S_{t} d Z_{t}\] where \(Z\) is a standard Brownian motion. Suppose the...
-
Calculate the solution to the following SDE: \[d X_{t}=\alpha\left(m-X_{t} ight) d t+\sigma d B_{t}\] with \(X_{0}=x\). The process satisfying this equation is called the meanreverting...
-
If \(X_{t} \sim N\left(0, \sigma^{2} t ight)\) and \(Y_{t}=e^{X_{t}}\), calculate the pdf of \(Y_{t}\). Calculate \(\mathbf{E}\left[Y_{t} ight]\) and \(V\left(Y_{t} ight)\). Calculate the transition...
Study smarter with the SolutionInn App