Filter Groups Using filter() in Python
📖 Scenario: You work in a small bookstore. You have a list of sales records. Each record shows the genre of the book sold and the number of copies sold that day.You want to find which genres sold more than 20 copies in total.
🎯 Goal: Build a Python program that groups sales by genre and uses filter() to keep only genres with total sales above 20.
📋 What You'll Learn
Create a list of sales records as tuples with genre and copies sold
Create a function to sum copies sold per genre
Use
filter() to keep genres with total sales above a thresholdPrint the filtered genres and their total sales
💡 Why This Matters
🌍 Real World
Filtering grouped data is common in sales analysis, customer segmentation, and many business reports.
💼 Career
Data analysts and scientists often need to filter groups of data based on summary statistics to find important trends.
Progress0 / 4 steps