Here is the Python program named rainfall.py that fulfills the requirements:
# Define an empty list to store monthly rainfall data
monthly_rainfall = []
# Loop through 12 months and collect user input for rainfall
for month_index in range(1, 13):
month_name = f"Month {month_index}"
rainfall = float(input(f"Enter the total rainfall for {month_name}: "))
monthly_rainfall.append(rainfall)
# Calculate total rainfall and average monthly rainfall
total_rainfall = sum(monthly_rainfall)
average_rainfall = total_rainfall / 12
# Find the month with the highest and lowest rainfall
highest_rainfall = max(monthly_rainfall)
lowest_rainfall = min(monthly_rainfall)
# Identify the month indexes for highest and lowest rainfall
highest_index = monthly_rainfall.index(highest_rainfall) + 1
lowest_index = monthly_rainfall.index(lowest_rainfall) + 1
# Display the results
print(f"Total rainfall: {total_rainfall:.1f}")
print(f"Average monthly rainfall: {average_rainfall:.2f}")
print(f"Month with highest rainfall: Month {highest_index} ({highest_rainfall:.1f} inches)")
print(f"Month with lowest rainfall: Month {lowest_index} ({lowest_rainfall:.1f} inches)")