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.
All 12 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.
- 02Variables 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.
- 03Numbers and OperatorsRun arithmetic live in the browser: the difference between / and //, what modulo returns, and how Python rounds when you mix ints and floats.
- 04Strings and SlicingStrings are sequences. Index into them, slice them with start:stop:step, and use the methods that make text manipulation read like English.
- 05Lists and IndexingBuild a list, reach into it by index, and see why Python counts positions from zero.
- 06DictionariesStore values under names instead of positions, look them up by key, and handle the key that is not there.
- 07Booleans and ComparisonsCompare values, combine them with and, or and not, and see which everyday values Python already treats as false.
- 08If, Elif and ElseBranch on a condition, and watch indentation decide which lines belong to which branch.
- 09For Loops and range()Loop over a list, count with range(), and accumulate a result across the passes of a for loop.
- 10While 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.
- 11Functions and Return ValuesDefine a function, pass it arguments, and see why printing a result is not the same as returning one.
- 12Reading 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.