Everyday Examples of Data Usage
Data analysis is no longer a special skill used only by companies.
It's now an integral part of the various services we use every day, often working behind the scenes without us even noticing.
For example, the following services rely heavily on data analysis:
- Streaming apps recommending content you might like
- Online shopping platforms offering personalized product suggestions
- Banks monitoring transactions to detect fraud
In this lesson, we'll use Python to practice one of the most basic data analysis tasks through hands-on exercises.
Python Warm-up: Calculating the Average
One of the most common concepts in data analysis is the average
.
The average is a basic metric used to represent the central tendency
of a dataset and is widely used to summarize data.
For example, let's calculate the average daily sales amount using price data from items sold over a week.
The formula for calculating the average is straightforward:
Average = Total sum of data ÷ Number of data points
In Python, you can easily implement this calculation using the built-in functions sum()
and len()
:
# Weekly sales data retrieved from an internal database sales_data = [8120, 9200, 7890, 10230, 8675, 9340, 10000] # Calculate total sales total_sales = sum(sales_data) # Divide by the number of days to get the average average_sales = total_sales / len(sales_data) # Print the result print("Average daily sales:", int(average_sales))
Checking the Result
Run the code on the right to check the result.
For small datasets, you can easily calculate the average using
sum()
andlen()
. However, when working with tens of thousands or even millions of data points, it's more efficient to use libraries likeNumPy
orPandas
for faster computations.
We'll explore how to leverage NumPy
and Pandas
in detail later.
In the next lesson, we'll dive into the difference between structured data and unstructured data.
Which Python function is used to calculate the total of all values in a list?
Lecture
AI Tutor
Design
Upload
Notes
Favorites
Help
Code Editor
Execution Result