0
0
Data Analysis Pythondata~30 mins

Aggregation functions (sum, mean, std) in Data Analysis Python - Mini Project: Build & Apply

Choose your learning style9 modes available
Aggregation functions (sum, mean, std)
📖 Scenario: You work in a small store and have a list of daily sales amounts in dollars. You want to understand the total sales, the average sales per day, and how much the sales vary from day to day.
🎯 Goal: Build a simple Python program that calculates the total sales, average sales, and standard deviation of sales from a list of daily sales amounts.
📋 What You'll Learn
Create a list of daily sales amounts with exact values
Create a variable to hold the number of days
Calculate the sum, mean, and standard deviation of the sales using Python code
Print the results clearly
💡 Why This Matters
🌍 Real World
Stores and businesses often analyze daily sales to understand performance and plan inventory.
💼 Career
Data analysts and business analysts use aggregation functions like sum, mean, and standard deviation to summarize and interpret data.
Progress0 / 4 steps
1
Create the sales data list
Create a list called daily_sales with these exact values: 150, 200, 170, 220, 180.
Data Analysis Python
Need a hint?

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

2
Create a variable for the number of days
Create a variable called num_days that stores the length of the daily_sales list using the len() function.
Data Analysis Python
Need a hint?

Use len(daily_sales) to get the number of items in the list.

3
Calculate sum, mean, and standard deviation
Calculate the total sales as total_sales using the sum() function on daily_sales. Calculate the average sales as average_sales by dividing total_sales by num_days. Calculate the standard deviation as std_dev using the formula: square root of the average of squared differences from the mean. Use import math and math.sqrt() for the square root.
Data Analysis Python
Need a hint?

Use a list comprehension to calculate squared differences from the mean.

4
Print the results
Print the total_sales, average_sales, and std_dev variables each on a separate line with clear labels using print().
Data Analysis Python
Need a hint?

Use print(f"Label: {variable}") to show the results clearly.