📖 Scenario: You work as a data analyst for a small online store. You have collected daily sales data for a week. You want to understand the basic statistics of these sales numbers to see how the store is performing.
🎯 Goal: Build a small program that uses the scipy.stats.describe function to get descriptive statistics of daily sales data.
📋 What You'll Learn
Create a list called daily_sales with exact sales numbers for 7 days
Import the describe function from scipy.stats
Use describe on the daily_sales list to get statistics
Print the result of the describe function
💡 Why This Matters
🌍 Real World
Descriptive statistics help businesses quickly understand their data, like sales trends or customer behavior.
💼 Career
Data analysts and scientists use descriptive statistics as the first step to explore and summarize data before deeper analysis.
Progress0 / 4 steps
1
Create the daily sales data list
Create a list called daily_sales with these exact values: 150, 200, 170, 220, 180, 210, 190.
SciPy
Hint
Use square brackets [] to create a list and separate numbers with commas.
2
Import the describe function
Import the describe function from the scipy.stats module.
SciPy
Hint
Use the from ... import ... syntax to import only the describe function.
3
Get descriptive statistics
Use the describe function on the daily_sales list and save the result in a variable called stats.
SciPy
Hint
Call describe with daily_sales inside the parentheses and assign it to stats.
4
Print the descriptive statistics
Print the variable stats to display the descriptive statistics.
SciPy
Hint
Use print(stats) to show the statistics on the screen.
Practice
(1/5)
1. What does the scipy.stats.describe function provide when applied to a dataset?
easy
A. Summary statistics like count, mean, variance, min, max, skewness, and kurtosis
B. Only the mean and median of the dataset
C. A plot showing data distribution
D. A list of unique values in the dataset
Solution
Step 1: Understand the purpose of scipy.stats.describe
This function is designed to give a quick summary of key statistics about the data.
Step 2: Identify the statistics returned
It returns count, mean, variance, minimum, maximum, skewness, and kurtosis, which describe data shape and spread.
Final Answer:
Summary statistics like count, mean, variance, min, max, skewness, and kurtosis -> Option A
Hint: Remember: describe summarizes data with key stats [OK]
Common Mistakes:
Thinking it returns only mean and median
Confusing it with plotting functions
Expecting a list of unique values
2. Which of the following is the correct way to import and use describe from scipy.stats?
easy
A. from scipy.stats import describe; result = describe(data)
B. import scipy.stats; result = describe(data)
C. from scipy import describe; result = describe(data)
D. import describe from scipy.stats; result = describe(data)
Solution
Step 1: Check correct import syntax for a function
Functions are imported using from module import function syntax in Python.
Step 2: Verify usage of describe after import
After importing, call describe(data) directly.
Final Answer:
from scipy.stats import describe; result = describe(data) -> Option A
Quick Check:
Correct import and call = from scipy.stats import describe; result = describe(data) [OK]
Hint: Use 'from scipy.stats import describe' to call directly [OK]
Common Mistakes:
Using wrong import syntax like 'import describe from ...'
Importing scipy.stats but not calling with module prefix
Importing from wrong module
3. Given the code below, what will be the output for the mean and min values?
import numpy as np
from scipy.stats import describe
data = np.array([2, 4, 6, 8, 10])
result = describe(data)
print(result.mean, result.minmax[0])
medium
A. 6.0 0
B. 5.0 2
C. 6.0 2
D. 5.0 0
Solution
Step 1: Calculate the mean of the data array
The data is [2, 4, 6, 8, 10]. Mean = (2+4+6+8+10)/5 = 30/5 = 6.0.
Step 2: Identify the minimum value from minmax
minmax returns (min, max). The minimum is 2.
Final Answer:
6.0 2 -> Option C
Quick Check:
Mean = 6.0, Min = 2 [OK]
Hint: Mean is average; min is smallest value [OK]
Common Mistakes:
Calculating mean incorrectly as 5.0
Confusing minmax tuple order
Assuming min is 0 without checking data
4. What is wrong with the following code snippet?
from scipy.stats import describe
data = [1, 2, 3, 4, 5]
result = describe(data, axis=1)
print(result)
medium
A. The print statement is missing parentheses
B. The data list should be converted to a numpy array first
C. The describe function requires a second argument for axis
D. Axis=1 is invalid for 1D data, causing an error
Solution
Step 1: Understand the data shape and axis parameter
The data is a 1D list. Axis=1 means operate along columns of 2D or higher arrays.
Step 2: Identify the error caused by axis=1 on 1D data
Using axis=1 on 1D data causes an AxisError because axis 1 does not exist.
Final Answer:
Axis=1 is invalid for 1D data, causing an error -> Option D
Quick Check:
Axis must exist in data shape [OK]
Hint: Check data dimensions before setting axis [OK]
Common Mistakes:
Assuming axis=1 works for 1D data
Thinking data must be numpy array for describe
Ignoring Python 3 print syntax
5. You have a dataset with some zero and negative values: data = [0, -1, 2, 3, 4]. Using scipy.stats.describe, which statistic helps you understand if the data distribution is skewed?
hard
A. Variance
B. Skewness
C. Count
D. Minimum
Solution
Step 1: Recall what skewness measures
Skewness shows if data is symmetric or leans left/right (skewed).
Step 2: Identify which statistic indicates skewness
Among the options, only skewness directly measures data asymmetry.
Final Answer:
Skewness -> Option B
Quick Check:
Skewness = data asymmetry [OK]
Hint: Skewness shows data leaning direction [OK]
Common Mistakes:
Confusing variance with skewness
Thinking count or minimum show skewness
Ignoring negative and zero values impact
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.