0
0
Data Analysis Pythondata~30 mins

Histograms in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Histograms
📖 Scenario: You work as a data analyst for a small bakery. You have collected data on the number of cookies sold each day for a week. You want to understand how the sales are distributed to help plan baking quantities better.
🎯 Goal: Build a simple program that creates a histogram of cookie sales data to visualize the frequency of sales numbers.
📋 What You'll Learn
Create a list of daily cookie sales numbers
Set a variable for the number of bins in the histogram
Use matplotlib to create a histogram of the sales data
Display the histogram plot
💡 Why This Matters
🌍 Real World
Histograms help businesses understand how often certain values occur, like daily sales, so they can make better decisions.
💼 Career
Data analysts and scientists use histograms to explore data distributions and communicate insights visually.
Progress0 / 4 steps
1
Create the sales data list
Create a list called cookie_sales with these exact daily sales numbers: 12, 15, 7, 10, 20, 13, 9.
Data Analysis Python
Hint

Use square brackets [] to create a list and separate numbers with commas.

2
Set the number of bins
Create a variable called bins and set it to 5 to define the number of bins for the histogram.
Data Analysis Python
Hint

Just assign the number 5 to the variable bins.

3
Create the histogram plot
Import matplotlib.pyplot as plt. Then use plt.hist() with cookie_sales and bins to create the histogram.
Data Analysis Python
Hint

Use import matplotlib.pyplot as plt to import. Then call plt.hist() with the list and bins.

4
Display the histogram
Use plt.show() to display the histogram plot.
Data Analysis Python
Hint

Call plt.show() to open the histogram window.