Write a function rainy_days (rainfall) which takes a nested list rainfall (type is NumPy array). Then, the function retu
Posted: Fri Jun 10, 2022 11:55 am
Write a function rainy_days (rainfall) which takes a nested list rainfall (type is NumPy array). Then, the function returns the day with the highest average rainfall observed in the rainfall measurements (day is represented by index 0 as Mon, index 1 as Tue, index 2 as Wed and so on). 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. If there are no valid weeks (all weekly measures are invalid), then the function returns None. You can assume all values in the NumPy array are numbers. For example: Test Result Fri 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], [0.2, 0.4, 0.9, 0.0, 1.5, 0.0, 1.6] ]) #avgs: 1.3, 0.9, 0.8, 1.7, 4.5, 0.5, 1.4 <- Friday has highest average print (rainy_days (rainfall)) rainfall = np.array([ None [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.4] ]) #all weeks are invalid measurements, so return None print (rainy_days (rainfall)) Answer: (penalty regime: 0, 10, ... %) Reset answer 1 import numpy as np