DataDriven
LearnPracticeInterviewDiscussDailyJobs

The Month-by-Month Snapshot

A medium Python interview practice problem on DataDriven. Write and execute real python code with instant grading.

Domain
Python
Difficulty
medium
Seniority
L4

Problem

Given a list of sales records (each a dict with 'employee_id', 'month', 'sales_amount'), return a list of per-employee dicts. For each employee, spread their sales across keys named after each month they sold in, using the month's lowercased three-letter abbreviation (e.g. 'January' -> 'jan', 'February' -> 'feb') as the key and the total sales for that employee-month as the value. Sum the amounts when the same employee has multiple records in the same month. Each output dict also carries the 'employee_id' key. Within each dict, place the month keys first in alphabetical order, then 'employee_id' last. The list of employee dicts is sorted alphabetically by employee_id.

Summary

Every salesperson has a story. The months just tell it sideways.

Practice This Problem

Solve this Python problem with real code execution. DataDriven runs your Python code in a real environment and grades it automatically.

Related

  • All Practice Problems
  • Mock Interview Mode
  • Python Interview Questions
  • Data Engineering Interview Prep Guide
  • Daily Challenge
  • Data Engineering Lessons