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.

Your progress0%

0 of 8 concepts completed

Complete the activity and related MCQ to unlock the next concept.

Concept 1LISTS

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.

01

Store

Values in a list.

02

Inspect

len, first, last.

03

Summarize

sum, min, max, average.

04

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

Lists for data

Store ordered collections of values.

len()

Inspect dataset size.

for loops

Process every value in the list.

sum / min / max

Quick numeric summaries.

for + if

Filter rows that meet a rule.

append()

Build a filtered list from matches.

Frequently Asked Questions

Common questions about working with data