0
0
NumPydata~15 mins

Combining conditions in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Filtering Data with Combined Conditions using NumPy
📖 Scenario: You work in a store and have a list of product prices. You want to find which products are both affordable and on sale.
🎯 Goal: Learn how to use NumPy to filter data by combining two conditions.
📋 What You'll Learn
Create a NumPy array with given prices
Create a price limit variable
Use combined conditions with NumPy to find affordable and on-sale products
Print the filtered prices
💡 Why This Matters
🌍 Real World
Filtering data with multiple conditions is common in sales, finance, and many other fields to find items that meet several criteria.
💼 Career
Data scientists and analysts often combine conditions to clean and analyze data efficiently using tools like NumPy.
Progress0 / 4 steps
1
Create the prices array
Create a NumPy array called prices with these exact values: 10, 25, 30, 45, 50, 60.
NumPy
Need a hint?

Use np.array([...]) to create the array with the given numbers.

2
Set the price limit
Create a variable called price_limit and set it to 40.
NumPy
Need a hint?

Just assign the number 40 to the variable price_limit.

3
Filter prices with combined conditions
Create a variable called affordable_and_on_sale that selects prices from prices which are less than price_limit and also less than 50. Use combined conditions with & and parentheses.
NumPy
Need a hint?

Use parentheses around each condition and combine them with & inside the brackets.

4
Print the filtered prices
Print the variable affordable_and_on_sale to see the filtered prices.
NumPy
Need a hint?

Use print(affordable_and_on_sale) to show the result.