Everyday Examples of Data Usage
Data analysis is no longer a special skill used only by companies.
It is seamlessly integrated into many of the services we use every single day.
For example, these services rely heavily on data analysis:
- Streaming apps recommend content you might enjoy
- Online shopping malls provide personalized product recommendations
- Banks monitor transactions to detect fraudulent activity
In this lesson, we'll use Python
to walk through one of the most basic data analysis tasks step by step.
Python Warm-up: Calculating the Average
One of the most commonly used concepts in data analysis is the average.
The average is a fundamental indicator of the central tendency of a dataset and is widely used to summarize data.
For example, let's calculate the average number of steps per day using step count data from the past week.
The formula for calculating an average is simple:
Average = Sum of Data ÷ Number of Data Points
In Python, we can easily implement this using the built-in functions sum()
and len()
.
# Daily step counts collected from a health-tracking app daily_steps = [8120, 9200, 7890, 10230, 8675, 9340, 10000] # Calculate the total number of steps total_steps = sum(daily_steps) # Divide by the number of days to get the average average_steps = total_steps / len(daily_steps) # Print the result print("Average daily steps:", int(average_steps))
Output
Run the code block on the right to check the result.
You'll see the average daily steps calculated based on the weekly data.
For small datasets,
sum()
andlen()
are more than enough to calculate averages. However, when working with tens of thousands or even millions of records, libraries like NumPy and Pandas are commonly used for faster and more efficient calculations.
We'll cover how to use NumPy
and Pandas
for these tasks in later lessons.
In the next lesson, we'll explore 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