
Data and engineering
Python for data
Real Python, running in your browser, with exercises designed for people who work with data.
- units
- 9
- lessons
- 26
- minutes
- 146
- exercises
- 156
The first unit is free, no credit card required. The other 8 unlock when you buy the course or go Pro. Single course: $12.99, one-time payment.
What's in the course.
From print to pandas, with code that really runs.
9 units, 26 lessons, and about 146 minutes of practice, a few minutes at a time.
Variables, types and text: the foundation for everything that follows.
In this unit, you'll learn to
- Store values in variables
- Recognise the int, float, str and bool types
- Build text with f-strings and string methods
Lessons
- Variables and types, unlocked6 exercises · 5 min
- Text and f-strings, unlocked6 exercises · 5 min
Store several values in lists and map keys to values with dictionaries.
In this unit, you'll learn to
- Access and slice lists
- Use sum, max, len and sorted
- Read and update dictionaries safely
Lessons
- Lists, locked6 exercises · 6 min
- Dictionaries, locked6 exercises · 5 min
- Tuples, sets, and nested data, locked6 exercises · 6 min
if to decide, for to repeat and comprehensions to transform lists in one line.
In this unit, you'll learn to
- Chain conditions with if, elif and else
- Loop over lists with for and range
- Filter and transform with list comprehensions
Lessons
- if, elif and else, locked6 exercises · 5 min
- for and comprehensions, locked6 exercises · 6 min
- zip, enumerate, while, and break, locked6 exercises · 6 min
Package reusable logic into functions and handle errors without crashing the program.
In this unit, you'll learn to
- Create functions with def and return
- Use parameters with default values
- Handle errors with try and except
Lessons
- def and return, locked6 exercises · 6 min
- Errors and exceptions, locked6 exercises · 6 min
- Functions that fail clearly, locked6 exercises · 6 min
Read CSVs, add up, group and sort data before you even reach for pandas.
In this unit, you'll learn to
- Read CSV files with the csv module
- Group values with dictionaries
- Sort with sorted, key and lambda
Lessons
- Reading CSVs, locked6 exercises · 6 min
- Grouping and sorting, locked6 exercises · 6 min
- Messy CSVs and richer groups, locked6 exercises · 6 min
Python's table library: read, filter, group and join data.
In this unit, you'll learn to
- Read and inspect a DataFrame
- Filter rows and select columns
- Translate SQL into pandas with groupby and merge
Lessons
- DataFrames, locked6 exercises · 5 min
- groupby and merge, locked6 exercises · 5 min
- Dtypes, missing, and Copy-on-Write, locked6 exercises · 5 min
Regex for messy text, JSON from APIs, date math, and tests so you can trust the result.
In this unit, you'll learn to
- Extract and validate text with regular expressions
- Read nested JSON and do math with dates
- Process line by line with generators and test with assert
Lessons
- Cleaning text with regex, locked6 exercises · 6 min
- API JSON and dates, locked6 exercises · 6 min
- Generators and tests, locked6 exercises · 6 min
Checked joins, summaries, and reshaped tables in pandas 3, in a project someone else can run.
In this unit, you'll learn to
- Join tables with validation and chain steps
- Summarize, reshape, and handle dates with agg, pivot_table, melt, and dt
- Isolate the environment, lock versions, and organize the script
Lessons
- Checked merges and chaining, locked6 exercises · 5 min
- Summaries, reshaping, and dates, locked6 exercises · 5 min
- Environments, scripts, projects, locked6 exercises · 5 min
A messy CSV from Tide Stationery becomes a reconciled summary, in plain Python.
In this unit, you'll learn to
- Validate row by row and set bad rows aside
- Summarize sales by store, category, and day
- Reconcile totals before delivering the file
Lessons
- Case: read and validate, locked6 exercises · 6 min
- Case: transform and summarize, locked6 exercises · 6 min
- Case: reconcile and deliver, locked6 exercises · 6 min
Try it for real.
Ready to code in Python? Real exercises from this course, solved step by step, exactly as they appear in the app.
156 exercises across 5 types in this course
- Write Python58
- Pick the best answer50
- Fill in the code26
- Match19
- Put it in order3
Write Python. Python 3 running in your browser, nothing to install. Write it, run it, see the output.
Profit is revenue minus cost. Print the profit rounded to 2 decimal places with round().
revenue = 1250.50 cost = 830.20 print(round(revenue - cost, 2))
Correct. Without round, the result comes out as 420.29999999999995, because decimal numbers are stored approximately. round(value, 2) fixes it for display.
Fill in the code. You pick the right piece from the word bank and see why the others don't fit.
The visits came from a spreadsheet as text. Fill in the blanks to print 2550.
visits_yesterday = "1200" visits_today = "1350" total = (visits_yesterday) + (visits_today) print(total)
Correct. int() turns each text into an integer, and then + adds them. Adding the texts directly would give "12001350".
Match. You link each situation to the right category, a few pairs at a time.
What is the type of each value?
- 42int
- 3.14float
- "42" (in quotes)str
- Truebool
Correct. Integers, decimals, text and true or false. Quotes always turn the value into text, even if it looks like a number.
Practice exams for this course
This course prepares you for these exams. Try free questions before you practice in the app.





