Month-over-month swings in energy demand
Energy traders watch sudden monthly jumps and drops in regional demand. The file energy.csv holds 24 months (2024-01 to 2025-12) for six regions.
month: YYYY-MMregion: region namemwh: consumption that month in MWh
For one region the rows appear in chronological order. Task: the first input line is a region, the second a threshold T (a number). For every month that has a previous month compute the percent change (mwh - previous) / previous x 100. Print one line MONTH CHANGE for each month whose absolute change is at least T, in chronological order, with CHANGE as a signed 2-decimal percent such as +12.34% or -8.10%. Finally print Biggest rise: MONTH CHANGE (the highest change, earliest month if tied). If the region has no rows print only No data.
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 15
Expected output
2024-05 -20.36% 2024-09 +18.99% 2024-11 +15.69% 2025-05 -21.07% 2025-12 +19.85% Biggest rise: 2025-12 +19.85%
Your answer is also checked against 5 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.
