Python for Data Analytics โข Lesson 19
Working with Python Data
Combine Python's core data structures, loops, conditions and functions to inspect, filter, transform and summarize a simple dataset.
0 of 8 concepts completed
Complete the activity and related MCQ to unlock the next concept.
Store Data in a List
Most Python analyses start with a collection of values. Lists are the simplest container โ ordered, indexable and easy to loop over.
Learn by Seeing
One variable, many values
sales = [12000, 18000, 9500, 22000] print(sales) # the whole list print(sales[0]) # first value print(sales[-1]) # last value
The list keeps the order you gave it, and you can read any value by index.
list
[12000, 18000, 9500, 22000]
indexed values
sales[0] ยท sales[-1]
Interactive Activity
How many values are stored in sales = [12000, 18000, 9500, 22000]?
Hint: Count the comma-separated items.
Python Analyst Mindset
Store, inspect, filter, summarize
Almost every small analysis in Python follows the same steps: hold the values in a list, loop over them, apply a rule, and produce a summary. Once you can chain those pieces, you can analyze any simple dataset.
Store
Values in a list.
Inspect
len, first, last.
Summarize
sum, min, max, average.
Filter
for + if + append.
Mini-Project
Top Performers Report
You have a list of monthly sales per salesperson. Find the team average, then build a filtered list of everyone who beat it. This is the exact pattern behind leaderboards, bonus eligibility, and performance dashboards.
sales = [85000, 125000, 140000, 45000, 210000]
average = sum(sales) / len(sales) # 121000.0
top = []
for s in sales:
if s > average:
top.append(s)
print("Team average:", average)
print("Top performers:", top)
# Team average: 121000.0
# Top performers: [125000, 140000, 210000]Every step uses something you learned in this lesson: a list to store the values, sum() and len() to compute the average, a for-loop with an if to filter, and append() to build the result.
Lesson Summary
What you learned
Store ordered collections of values.
Inspect dataset size.
Process every value in the list.
Quick numeric summaries.
Filter rows that meet a rule.
Build a filtered list from matches.
Frequently Asked Questions