0
0
NumPydata~15 mins

Comparison operations in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Comparison operations
📖 Scenario: You work in a store that tracks daily sales numbers. You want to find which days had sales above a certain target.
🎯 Goal: Build a small program using numpy to compare daily sales numbers against a sales target and find which days met or exceeded the target.
📋 What You'll Learn
Use numpy arrays to store sales data
Create a sales target variable
Use comparison operations to find days with sales >= target
Print the boolean array showing which days met the target
💡 Why This Matters
🌍 Real World
Stores and businesses often compare daily sales or performance numbers against targets to see which days did well.
💼 Career
Data analysts and scientists use comparison operations to filter and analyze data quickly and efficiently.
Progress0 / 4 steps
1
Create the sales data array
Create a numpy array called sales with these exact daily sales numbers: 120, 85, 90, 150, 110.
NumPy
Need a hint?

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

2
Set the sales target
Create a variable called target and set it to the integer 100.
NumPy
Need a hint?

Just assign the number 100 to the variable target.

3
Compare sales to the target
Create a variable called above_target that stores the result of comparing sales to target using the >= operator.
NumPy
Need a hint?

Use the >= operator between the sales array and the target variable.

4
Print the comparison result
Print the variable above_target to show which days had sales greater than or equal to the target.
NumPy
Need a hint?

Use print(above_target) to display the boolean array.