Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Learn Challenge: Identify Largest Yearly Increase in Service Usage | Data Analysis for Public Sector Insights
Practice
Projects
Quizzes & Challenges
Quizzes
Challenges
/
Python for Government Analysts

bookChallenge: Identify Largest Yearly Increase in Service Usage

Tracking trends in service usage is essential for effective resource planning in government. Understanding when and how usage spikes can help you allocate funding, staff, and infrastructure more efficiently, ensuring that public services meet citizen demand without waste or shortfall. By analyzing year-over-year changes, you can identify periods of rapid growth or decline, which may signal the need for policy adjustments or further investigation.

1234567
service_usage_data = [ {"year": 2018, "usage_count": 1200}, {"year": 2019, "usage_count": 1350}, {"year": 2020, "usage_count": 1700}, {"year": 2021, "usage_count": 2000}, {"year": 2022, "usage_count": 1850}, ]
copy

To find the largest yearly increase in service usage, you first calculate the difference in usage_count between each consecutive year. By comparing each year's count with the previous year's, you can determine the size of the increase or decrease. Once you have all the year-over-year differences, identify the pair with the greatest positive change. The year in which this largest increase occurs is the later year in the pair, and the value of the increase is the difference between the two years' usage counts.

Task

Swipe to start coding

Given a list of dictionaries with yearly service usage data, identify the year with the largest increase in usage compared to the previous year. The function should return a tuple containing the year and the amount of the largest increase.

  • Compare each year's usage_count to the previous year's value.
  • Find the maximum positive difference between consecutive years.
  • Return the year in which the largest increase occurred and the value of the increase as a tuple.

Solution

Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 5
single

single

Ask AI

expand

Ask AI

ChatGPT

Ask anything or try one of the suggested questions to begin our chat

close

bookChallenge: Identify Largest Yearly Increase in Service Usage

Swipe to show menu

Tracking trends in service usage is essential for effective resource planning in government. Understanding when and how usage spikes can help you allocate funding, staff, and infrastructure more efficiently, ensuring that public services meet citizen demand without waste or shortfall. By analyzing year-over-year changes, you can identify periods of rapid growth or decline, which may signal the need for policy adjustments or further investigation.

1234567
service_usage_data = [ {"year": 2018, "usage_count": 1200}, {"year": 2019, "usage_count": 1350}, {"year": 2020, "usage_count": 1700}, {"year": 2021, "usage_count": 2000}, {"year": 2022, "usage_count": 1850}, ]
copy

To find the largest yearly increase in service usage, you first calculate the difference in usage_count between each consecutive year. By comparing each year's count with the previous year's, you can determine the size of the increase or decrease. Once you have all the year-over-year differences, identify the pair with the greatest positive change. The year in which this largest increase occurs is the later year in the pair, and the value of the increase is the difference between the two years' usage counts.

Task

Swipe to start coding

Given a list of dictionaries with yearly service usage data, identify the year with the largest increase in usage compared to the previous year. The function should return a tuple containing the year and the amount of the largest increase.

  • Compare each year's usage_count to the previous year's value.
  • Find the maximum positive difference between consecutive years.
  • Return the year in which the largest increase occurred and the value of the increase as a tuple.

Solution

Switch to desktopSwitch to desktop for real-world practiceContinue from where you are using one of the options below
Everything was clear?

How can we improve it?

Thanks for your feedback!

SectionΒ 1. ChapterΒ 5
single

single

some-alt