Learn Python by running it.
Free lessons from the first print statement to machine learning, written for students and anyone starting out. Read a little, run the code, change it, run it again.
# Every example on this site runs right here in your browser.
# Change something and press Run.
marks = {"Asha": 88, "Bilal": 72, "Chitra": 95, "Dev": 60}
passed = [name for name, m in marks.items() if m >= 70]
print("Passed:", ", ".join(passed))
print("Class average:", sum(marks.values()) / len(marks))Resources
Python
Python from the first print statement to machine learning, with code you can run in the page.
- Python basics, 38 lessons
- Machine learning, 24 lessons
More on the way
New resources are added here as they are written. Python is the first; check back for the next one.
How the lessons work
Short and in order
Each lesson covers one idea and builds on the last. The sidebar keeps your place and shows what you have finished.
Code you can change
Every Python example has a Run button. Edit the code in place to test a guess, then reset it to the original.
Nothing to install
Python runs inside your browser, including NumPy, pandas and scikit-learn. Your work stays on your machine.
Practice at the end
Most lessons finish with a few tasks. Doing them in the playground is what makes the ideas stick.
