Rainfall
The following program is designed to use a list of daily rainfall amounts to calculate the average daily rainfall. The list may contain the number -999 indicating the end of the data of interest. Produce the average of the non-negative values in the list up to the first -999 (if it shows up).
There may be negative numbers other than -999 in the list. These values are errors, and should not be used in calculating rainfall amounts or days.
If no days of data are valid, the program should report an average of 0, rather than an error.
#!/usr/bin/env python3 """ rainfall.py This program uses a function to take a list of daily rainfall values and calculate the average of them. """ def rainfall_average(list_of_daily_values): """The list may contain the number -999 indicating the end of the data of interest. Produce the average of the non-negative values in the list up to the first -999 (if it shows up). There may be negative numbers other than -999 in the list. """ # Your code goes here def main(): print("Testing rainfall inputs") # You can put in test values for v1 through v5 below daily_rainfall = [v1, v2, v3, v4, v5] print(rainfall_average(daily_rainfall)) if __name__ == "__main__": main()