0
0
NumPydata~15 mins

Percentiles with np.percentile() in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Calculate Percentiles with np.percentile()
📖 Scenario: You work in a small bakery that tracks daily sales of different bread types. You want to understand how sales vary by calculating percentiles, which help you see the sales distribution.
🎯 Goal: Build a simple program that calculates the 25th, 50th, and 75th percentiles of daily bread sales using np.percentile().
📋 What You'll Learn
Create a numpy array with daily sales data
Set a list of percentiles to calculate
Use np.percentile() to find the percentile values
Print the percentile results clearly
💡 Why This Matters
🌍 Real World
Percentiles help businesses understand data spread, like how many sales fall below a certain value.
💼 Career
Data analysts and scientists use percentiles to summarize and explain data distributions clearly.
Progress0 / 4 steps
1
Create the sales data array
Create a numpy array called sales with these exact daily sales numbers: 20, 35, 30, 35, 27, 25, 40, 50, 29, 30.
NumPy
Need a hint?

Use np.array() and put the numbers inside square brackets.

2
Set the percentiles to calculate
Create a list called percentiles with these exact values: 25, 50, 75.
NumPy
Need a hint?

Use square brackets to create a list with the three numbers.

3
Calculate the percentile values
Use np.percentile() with the sales array and the percentiles list to create a variable called percentile_values that stores the results.
NumPy
Need a hint?

Call np.percentile() with the sales array and the percentiles list as arguments.

4
Print the percentile results
Print the percentile_values variable to display the 25th, 50th, and 75th percentiles of sales.
NumPy
Need a hint?

Use print() to show the percentile_values array.