What this site is
LearnPY is a small, focused curriculum for Python's data stack. Each lesson gives you one mental model, a few short examples, and a place to run real code. Everything executes in your browser, so there is nothing to install and no account to create.
- Lessons are short on purpose. Finish one idea, then move on.
- Code is real Python. The arrays, tables, plots, and models are the same ones you would use locally.
- You can edit every runnable example. Change a value, break it, and run it again.
The loop you will repeat
Most lessons follow the same rhythm. It is deliberately boring: read a little, type a little, check the result. That loop is what turns syntax you recognize into code you can write.
- Read the explanation and predict what the code will do.
- Run the example, then change one thing and run it again.
- Work through the exercise without copying the solution.
- Answer the quiz question and read the explanation, even when you get it right.
- Use the reference pages when you need a signature instead of a lesson.
for value in [3, 6, 9]:
print(value * 2)Output
6 12 18
Run your first cell
The panel below is a live Python session. Press Run to execute it. The first run downloads the Python runtime and can take a few seconds; later runs reuse the same session and start immediately.
Python
Your first cell
Output
Press Run to execute this cell. The first run downloads Python; later runs reuse the session.
The last line is an expression, so the runner shows its value separately from the printed output. That mirrors the behavior of a notebook: print what a reader needs, and leave the final expression for a quick look.
What each track covers
The four tracks share one vocabulary. NumPy introduces arrays, pandas builds labeled tables on top of them, Matplotlib turns values into charts, and scikit-learn turns clean tables into models. Taking them in that order makes each track easier.
| Track | What you will practice | When to take it |
|---|---|---|
| NumPy | Arrays, broadcasting, indexing, random numbers, linear algebra | First |
| pandas | DataFrames, selection, grouping, joins, cleaning | After NumPy basics |
| Matplotlib | Figures, axes, layouts, styling, subplots | Alongside pandas |
| scikit-learn | Preprocessing, regression, classification, clustering, metrics | After pandas and NumPy |
When something breaks
An error is information, not a verdict. Read the last line first: it names the error. Then scan upward for the line number in your code. Most beginner errors come from a missing quote, a missing colon, inconsistent indentation, or a name that was never defined.
- NameError means Python has not seen that variable yet. Check spelling and whether the defining line ran.
- IndentationError means the block structure is off. Use four spaces per level and do not mix tabs.
- ModuleNotFoundError usually means the package was not loaded. Lessons load what they need, but imports still have to be written.
What comes next
You do not need to memorize this page. Start the NumPy track, keep the reference pages nearby, and come back here whenever you want a reminder of how the lessons fit together.
Practice
Make it stick
Run the tests as often as you like. Hints and the solution are available when you need them.
Exercise
Add the new reading of 20 to the list, then compute the updated average.
Your solution
ReadyResults
Run the tests to check your solution. The first run downloads Python; later runs reuse the session.
Quiz
Check your understanding
Lesson progress