Page 1 of 1

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
by correctanswer
Write A Function Rainy Days Rainfall Which Takes A Nested List Rainfall Type Is Numpy Array Then The Function Retu 1
Write A Function Rainy Days Rainfall Which Takes A Nested List Rainfall Type Is Numpy Array Then The Function Retu 1 (244.31 KiB) Viewed 73 times
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 Re rainfall = np.array([ 2 [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] 1) #week 1 total 18.2 #week 2 total 10.6 #week 3 total 4.6 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] ]) #all weeks are invalid measurements, so return -1 print (rainy_days (rainfall)) -1