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...
-
Sara Nixon is looking for a fixed-income investment. She is considering two bond issues: a. A Treasury with a yield of 5% b. An in-state municipal bond with a yield of 4% Sara is in the 33% federal...
-
The following are the summarised balance sheets of P Ltd and S Ltd at 31 December 19X6. There were no additions or disposals of fixed assets by the group during the year. (b) P Limited acquired its...
-
What is the probability that at least one \(A\) is showing? We are considering two special 6 -sided dice. Each face is labeled with a number and a letter: the first die has faces \(1 A, 1 B, 2 A, 2...
-
Bush-Caine Company reported the following data on its December 31, 2006 balance sheet: Preferred stock, $50 par $50,000 Common stock , $10 par $100,000 Additional paid-in capital on preferred stock...
-
Case study: The cost of strike action in South Africa South Africas workdays lost due to strike action rose more than 30-fold from January to June 2022 compared with the same period a year earlier,...
-
Best Buy Co., Inc. is a leading provider of technology products. Customers can shop at more than 1,700 stores or online. The company is also known for its Geek Squad for technology services. Suppose...
-
Using ECLIPSE JAVA I an creating a java program where user inputs key words for a song/artist and the program provides songs and artists that correspond (provide the end-user with the functionality...
-
Which of the following steps can a generalized computer not perform: a. Add data. b. Select a statistical sample. c. Prepare a summary of findings and conclusions. d. Array data according to...
-
What actions are required of internal auditors who suspect fraud? What responsibility do internal auditors owe to the public in the event they encounter fraud in high places in their organization?
-
What are the page limitations for memorandum of points and authorities?
-
What risks do payroll activities pose for employers?
-
What are some reasons for a formal charter for internal auditors ^thin a company?
-
Hi I need help on what is the answer in my activity, the requirement is to compute for the adjusted balances for sales, purchases and inventories, respectively Sales Purchases Inventories I hope that...
-
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...
-
The Mendoza Company is installing an absorption standard-costing system and a flexible-overhead budget. Standard costs have recently been developed for its only product and are as follows: Expected...
-
The expected activity of the paper-making plant of Leventhal Paper Company was 45,000 machine hours per month. Practical capacity was 60,000 machine hours per month. The standard machine hours...
-
Precision AutoParts Company has a highly automated manufacturing process for producing a variety of auto parts. Through the use of computer-aided manufacturing and robotics, the company has reduced...
Study smarter with the SolutionInn App