└── environmental pollution /environmental pollution: -------------------------------------------------------------------------------- 1 | # Example data for monthly CO2 emissions (in metric tons) for each factory 2 | # Factories: [Factory1, Factory2, Factory3] 3 | monthly_emissions = { 4 | 'Factory1': [10.5, 11.2, 10.8, 9.6, 11.0, 10.3, 11.5, 12.0, 10.9, 10.0, 9.8, 11.1], 5 | 'Factory2': [5.5, 5.2, 5.8, 5.6, 5.0, 5.3, 5.5, 5.0, 4.9, 5.0, 5.1, 5.2], 6 | 'Factory3': [7.5, 7.8, 7.6, 7.9, 8.0, 7.4, 7.5, 7.7, 7.8, 7.9, 7.6, 7.5] 7 | } 8 | 9 | def calculate_annual_emissions(emissions): 10 | # Initialize total annual emissions 11 | total_annual_emissions = {} 12 | 13 | # Calculate the total emissions for each factory 14 | for factory, monthly_values in emissions.items(): 15 | annual_total = sum(monthly_values) 16 | total_annual_emissions[factory] = annual_total 17 | 18 | return total_annual_emissions 19 | 20 | def main(): 21 | annual_emissions = calculate_annual_emissions(monthly_emissions) 22 | 23 | # Output the results 24 | for factory, total_emission in annual_emissions.items(): 25 | print(f"The total annual CO2 emissions of {factory} are {total_emission:.2f} metric tons") 26 | 27 | if __name__ == "__main__": 28 | main() 29 | --------------------------------------------------------------------------------