Write a function rainy_days (rainfall) which takes a nested list rainfall (type is NumPy array). Then,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Write a function rainy_days (rainfall) which takes a nested list rainfall (type is NumPy array). Then, the function returns the week with the lowest rainfall observed. Week index starts from 0 (i.e., the first row is week 0, the second row is week 1 etc.). If the week's data does not contain each day's information (i.e., some data missing or extra days added), then that week's data is ignored wholly (but it is still counted as a week). If there are no valid weeks (all weekly measures are invalid), then the function returns -1. You can assume all values in the NumPy array are numbers. You can also assume no two weeks will have to same average rainfalls. For example: Test rainfall = np.array([ [0.2, 0.0, 1.6, 4.8, 9.0, 1.2, 1.4), [3.6, 2.2, 0.0, 0.2, 3.0, 0.3, 1.3], #week 1 total 18.2. #week 2 total 10.6 [0.2, 0.4, 0.9, 0.0, 1.5, 0.0, 1.6 1, #week 3 total 4.6 dtype=object) print (rainy_days (rainfall)) rainfall = np.array( [ [0.2, 0.0, 1.6, 4.8, 0.0, 1.2], [0.2, 0.4, 0.9, 0.0, 1.5, 0.0, 1.6, 0.41 ], dtype=object) #all weeks are invalid measurements, so return -1 print (rainy_days (rainfall)) Result 2 -1 Write a function rainy_days (rainfall) which takes a nested list rainfall (type is NumPy array). Then, the function returns the week with the lowest rainfall observed. Week index starts from 0 (i.e., the first row is week 0, the second row is week 1 etc.). If the week's data does not contain each day's information (i.e., some data missing or extra days added), then that week's data is ignored wholly (but it is still counted as a week). If there are no valid weeks (all weekly measures are invalid), then the function returns -1. You can assume all values in the NumPy array are numbers. You can also assume no two weeks will have to same average rainfalls. For example: Test rainfall = np.array([ [0.2, 0.0, 1.6, 4.8, 9.0, 1.2, 1.4), [3.6, 2.2, 0.0, 0.2, 3.0, 0.3, 1.3], #week 1 total 18.2. #week 2 total 10.6 [0.2, 0.4, 0.9, 0.0, 1.5, 0.0, 1.6 1, #week 3 total 4.6 dtype=object) print (rainy_days (rainfall)) rainfall = np.array( [ [0.2, 0.0, 1.6, 4.8, 0.0, 1.2], [0.2, 0.4, 0.9, 0.0, 1.5, 0.0, 1.6, 0.41 ], dtype=object) #all weeks are invalid measurements, so return -1 print (rainy_days (rainfall)) Result 2 -1
Expert Answer:
Answer rating: 100% (QA)
Below is a Python function that meets the specified requirements import numpy as np def rainydaysrai... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
The figure represents a portion of a direction field of an autonomous first-order differential equation dy/dx = f (y). Reproduce the figure on a separate piece of paper and then...
-
Imagine that marketing researchers working for a food company want to determine whether children would prefer ketchup of a different color. They develop red, green, and blue ketchups that all taste...
-
For the data points in Exercise 5.5.9, determine the plane z = + x + y that fits the data in the least squares sense when the errors are weighted according to the reciprocal of the distance of the...
-
Which of the following statements is true for real gases? Choose all that apply. 1. As attractive forces between molecules increase, deviations from ideal behavior become more apparent at relatively...
-
What is the color of visible light of the lowest frequencies? Of the highest frequencies?
-
Irvin Smith was charged in a Georgia state court with burglary and theft. Before the trial, during the selection of the jury, the state prosecutor asked the prospective jurors whether they knew...
-
Which of the following is not an element of an internal control system? a. Auditing b. The control environment C. Monitoring d. Information and communication
-
As the manager of Margarita Mexican Restaurant, you must deal with a variety of business transactions. Provide an explanation for the following transactions: a. Debit Equipment and credit Cash. b....
-
SOUTHWEST AIRLINES: PROFILE OF A LEADER Airlines have faced economic difficulties with rising fuel costs and increased security standards. While many airlines have faced bankruptcy and corpo- rate...
-
Marider Industries makes two types of windbreaker jackets: one for spring and one for winter. Marider uses a traditional costing system and is considering switching to an Activity-Based Costing...
-
January Activity to review and record, respond as applicable S Board Feet $ 3,200.00 2,000.00 3-Jan 4-Jan 4-Jan Strong Construction purchases lumber on account. The manager pays the BWLC for December...
-
Why did the European Monetary System fail? How does the euro differ from the EMS? Were the lessons from the EMS failure learned when the euro was designed?
-
Would the euro-zones economic problems be alleviated if the currency were to depreciate significantly against the U.S. dollar and the Japanese yen? Which euro-zone country would benefit the most?...
-
Write short notes on the following: (a) Standard costing as tool of management control. (b) Control through standard costs.
-
Should Greece exit the euro-zone? What would be the implications for Greece versus the euro-zone and the European Union?
-
What are the key macroeconomic variables that explained devaluation or revaluation in the Bretton Woods system?
-
Timo started working as a craftsperson which will pay him $4,000 per month. He anticipates a 0.2% monthly increase in the paycheck. All of his savings are invested in ETF, which has an expected...
-
Use Stokes' Theorem to evaluate f(y+sin x) dx+(z+cos y) dy+rdz, where C is the rve r(t) = (sint, cost, sin 2t), t = [0, 2].
-
Describe the difference between hardware and software and identify two examples of each type?
-
Alan Turing is considered one of computer science's founding fathers. Describe two of his contributions to the discipline, and explain the importance of those contributions?
-
Create a Web page named remainder.html that contains a text box and a button. When the button is clicked, JavaScript statements should (1) access the number entered in the text box, (2) calculate the...
-
Provide an example of two samples that are independent. Explain why these samples are independent.
-
Why is it necessary for all values in the confidence interval to be positive to conclude that 1 > 2? What would have to be true to conclude that 1 < 2?
-
Provide an example of two samples that are paired. Explain why these samples are paired.
Study smarter with the SolutionInn App