0
0
NumPydata~15 mins

np.mean() for average in NumPy - Mini Project: Build & Apply

Choose your learning style9 modes available
Calculate Average Using np.mean()
📖 Scenario: You work in a small bakery. You have daily sales numbers for a week. You want to find the average sales to understand how well the bakery is doing.
🎯 Goal: Calculate the average daily sales using np.mean() from the sales data.
📋 What You'll Learn
Create a numpy array called sales with the exact daily sales numbers
Create a variable called average_sales to store the average
Use np.mean() to calculate the average of sales
Print the value of average_sales
💡 Why This Matters
🌍 Real World
Calculating averages is common in business to understand typical performance, like average sales per day.
💼 Career
Data analysts and scientists often use averages to summarize data and find trends.
Progress0 / 4 steps
1
Create the sales data array
Create a numpy array called sales with these exact daily sales numbers: 120, 150, 130, 170, 160, 180, 140.
NumPy
Need a hint?

Use np.array() to create the array with the exact numbers inside square brackets.

2
Create a variable for the average
Create a variable called average_sales and set it to 0 as a starting point.
NumPy
Need a hint?

Just write average_sales = 0 to create the variable.

3
Calculate the average using np.mean()
Use np.mean() on the sales array and assign the result to average_sales.
NumPy
Need a hint?

Use average_sales = np.mean(sales) to calculate the average.

4
Print the average sales
Print the value of average_sales to see the average daily sales.
NumPy
Need a hint?

Use print(average_sales) to display the average.