import matplotlib.pyplot as plt
# Updated rainfall data in mm (e.g., daily rainfall over 12 days)
rainfall_data = [5, 12, 7, 0, 22, 9, 3, 15, 6, 18, 20, 8] # Modify with actual data
time_period = list(range(1, len(rainfall_data) + 1)) # Time periods, e.g., days
# Calculations
total_rainfall = sum(rainfall_data)
average_rainfall = total_rainfall / len(rainfall_data)
max_rainfall = max(rainfall_data)
# Print the results
print(f"Total Rainfall: {total_rainfall} mm")
print(f"Average Rainfall: {average_rainfall:.2f} mm")
print(f"Maximum Rainfall: {max_rainfall} mm")
# Plotting the rainfall data
plt.figure(figsize=(10, 5))
plt.plot(time_period, rainfall_data, marker='o', linestyle='-', color='g')
plt.title('Rainfall Precipitation Analysis')
plt.xlabel('Time Period (e.g., Days)')
plt.ylabel('Rainfall (mm)')
plt.grid(True)
plt.show()
Click Run or press shift + ENTER to run code