Peak power month of a region
A grid operator plans maintenance outside the busiest month of each region. Monthly consumption is stored in energy.csv for 2024 and 2025.
month: YYYY-MMregion: region name (for example Iberia or US Midwest)mwh: electricity consumed that month in megawatt-hours (whole number)
Task: the first input line is a region (exactly as in the file), the second line a year such as 2025. Print two lines: Total MWh: T (sum over that region and year) and Peak month: M (V MWh) where M is the month with the highest consumption and V its value. If two months tie, print the earlier one. If there is no data, print No data on a single line instead.
Files your program can read
month,region,mwh 2024-01,Northern Europe,6492 2024-01,Iberia,3956 2024-01,US Midwest,8847 2024-01,South Asia,4739 2024-01,East Africa,1638 2024-01,Patagonia,721 2024-02,Northern Europe,6529 ...
Open them by name, for example open("energy.csv").
Sample test
Input
Iberia 2025
Expected output
Total MWh: 37134 Peak month: 2025-01 (3872 MWh)
Your answer is also checked against 4 hidden tests.
Log in or create a free account to run your code, submit and earn points.
Run your code to see the output here. Ctrl + Enter also runs it.
