Python, by Running It
The language every other track assumes. Real code, run in your browser, from your first print to your first functions.
About this track
Every other track on this site writes Python in its examples, and every one of them assumes you already speak it. This is where you learn it - not from reading, but from running. Every module embeds a real Python interpreter, so the code on the page is not a screenshot: you can change it and press Run and see what actually happens.
The track starts at your first print statement and works up through variables, numbers, strings, lists, conditionals and functions - the handful of ideas every later module leans on.
Every page runs real Python in the browser, with no installation and no setup. The code on screen is the code that executes, so an error you cause is a real traceback rather than a description of one.
What you will be able to do
- Write and run a program that takes input, decides something, and prints a result.
- Choose between a list, a dictionary and a string for a given job.
- Use loops and conditionals without guessing at indentation or off-by-one bounds.
- Write functions that return values, and explain why a missing return gives you None.
- Read a traceback and find the line that actually caused it.
How the track is ordered
The track starts at your first print statement and adds one idea at a time: variables and types, numbers and operators, strings and slicing, lists and indexing, booleans and comparisons, conditionals, loops, dictionaries, and functions. It ends on reading errors, which is the skill that makes everything else self-teachable. Nothing is assumed - not a prior language, not an installed interpreter, not a terminal.
Where this leads
Every other track on this site writes Python in its examples and assumes you can read it. Once functions and dictionaries are comfortable, the algorithms track is the natural next step, since its data structure pages are the same objects examined more carefully.
All 46 modules, in teaching order
- 01Hello, Python!Write your first print statement in a real in-browser Python interpreter and watch strings, numbers and newlines come out the other side.
- 02input() and Output
- 03Variables and TypesAssign a name and ask Python what it is. See the types Python tracks for you and why the same value behaves differently depending on what it is.
- 04Type Conversion
- 05Numbers and OperatorsRun arithmetic live in the browser: the difference between / and //, what modulo returns, and how Python rounds when you mix ints and floats.
- 06Strings and SlicingStrings are sequences. Index into them, slice them with start:stop:step, and use the methods that make text manipulation read like English.
- 07String Methods
- 08Slicing with Step
- 09f-strings and Formatting
- 10Lists and IndexingBuild a list, reach into it by index, and see why Python counts positions from zero.
- 11Mutability and Aliasing
- 12Shallow vs Deep Copying
- 13sorted() with key=
- 14DictionariesStore values under names instead of positions, look them up by key, and handle the key that is not there.
- 15Dictionary Methods
- 16Nested Data Structures
- 17Tuples and Unpacking
- 18Sets and Set Operations
- 19Booleans and ComparisonsCompare values, combine them with and, or and not, and see which everyday values Python already treats as false.
- 20None and Truthiness
- 21If, Elif and ElseBranch on a condition, and watch indentation decide which lines belong to which branch.
- 22Nested Conditionals
- 23Conditional Expressions
- 24match and case
- 25try and except
- 26For Loops and range()Loop over a list, count with range(), and accumulate a result across the passes of a for loop.
- 27Nested For Loops
- 28for/else and while/else
- 29range() with step
- 30enumerate()
- 31zip()
- 32List Comprehensions
- 33Conditional Comprehensions
- 34Dict and Set Comprehensions
- 35While Loops, break and continueLoop while a condition holds, exit early with break, skip a pass with continue, and see what makes a loop run forever.
- 36Functions and Return ValuesDefine a function, pass it arguments, and see why printing a result is not the same as returning one.
- 37Function Arguments
- 38*args and **kwargs
- 39lambda, map and filter
- 40Variable Scope
- 41Reading Errors and TracebacksRead a traceback from the bottom up, recognise the common Python error types, and turn each message into the fix it points at.
- 42Files and with
- 43Modules and import
- 44Generators and yield
- 45Classes and Objects
- 46Inheritance