help pls, make it pylint compatible
Write a function rainy_days (rainfall) which takes a nested list rainfall (type is NumPy array). Then, the function returns the week with the highest 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], #week 1 total 18 [3.6, 2.2, 0.0, 0.2, 3.0, 0.3, 1.3], #week 2 total 16 [0.2, 0.4, 0.9, 0.0, 1.5, 0.0, 1.6] 1) #week 3 total 4. 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.4] 1) #all weeks are invalid measurements, so return -1 print (rainy_days (rainfall))
For example: np.array([ 0.0, 1.6, 4.8, 9.0, 1.2, 1.4], 3 2.2, 0.0, 0.2, 3.0, 0.3, 1.3], 3 , 0.4, 0.9, 0.0, 1.5, 0.0, 1.6] ]) y_days (rainfall)) np.array([ , 0.0, 1.6, 4.8, 0.0, 1.2], 0.4, 0.9, 0.0, 1.5, 0.0, 1.6, 0.4] ]) > are invalid measurements, so return -1 y_days (rainfall)) #week 1 Total 18.2 #week 2 total 10.6 #week 3 total 4.6 Result 0 -1
help pls, make it pylint compatible
-
- Posts: 43759
- Joined: Sat Aug 07, 2021 7:38 am