User Defined Functions in Python
Overview Let’s write a Python program with a user-defined function to calculate a year’s total and average rainfall. Python Program #———————————————– #Calculate total rainfall for the duration in months #———————————————– def total_rainfall(rainfall, durationInMonths): total = 0 for i in range(durationInMonths): total +=rainfall[i] return total #———————————————– #Calculate the average rainfall for a month #———————————————– def average_rainfall(rainfall, […]