0
0
Data Analysis Pythondata~15 mins

Boolean filtering in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Boolean Filtering
📖 Scenario: You work in a small store and have a list of products with their prices. You want to find which products are affordable for customers who want to spend less than a certain amount.
🎯 Goal: Build a program that filters products based on a price limit using boolean filtering.
📋 What You'll Learn
Create a dictionary with product names as keys and prices as values
Create a variable for the price limit
Use boolean filtering to select products cheaper than the price limit
Print the filtered products
💡 Why This Matters
🌍 Real World
Filtering data based on conditions is common in stores, websites, and apps to show users only relevant items within their budget.
💼 Career
Data filtering is a basic skill for data analysts and scientists to prepare and analyze data efficiently.
Progress0 / 4 steps
1
Create the product price dictionary
Create a dictionary called products with these exact entries: 'apple': 120, 'banana': 80, 'cherry': 150, 'date': 60, 'elderberry': 200.
Data Analysis Python
Need a hint?

Use curly braces to create a dictionary with product names as keys and prices as values.

2
Set the price limit
Create a variable called price_limit and set it to 100.
Data Analysis Python
Need a hint?

Just assign the number 100 to the variable price_limit.

3
Filter products cheaper than the price limit
Create a dictionary called affordable_products using a dictionary comprehension that includes only products from products with prices less than price_limit. Use for product, price in products.items() in your comprehension.
Data Analysis Python
Need a hint?

Use a dictionary comprehension with an if condition to filter products.

4
Print the affordable products
Print the affordable_products dictionary.
Data Analysis Python
Need a hint?

Use print(affordable_products) to show the filtered dictionary.