Python Lab · Python course

Learn to program, one small step at a time.

From your very first line of code to files, algorithms and classes. Every lesson is short explanations and code you run straight away, checked as you go, with nothing to install.

Chapter 1 is open to everyone. Chapters 2 to 17 are being written. Your progress is saved on this device, and on your account if you're signed in.

Chapters

Chapter 1Hello, Pythonprint(), text, comments, and reading your first error.Project: a name badge6 lessonsChapter 2VariablesStoring values, naming things, numbers, text and True/False.Project: an about-me card6 lessonsChapter 3Numbers and mathsOperators, // and %, order of operations, rounding.Project: a pizza splitter6 lessonsChapter 4Input and outputinput(), converting text to numbers, f-strings.Project: a silly-story maker6 lessonsChapter 5Making decisionsif, elif, else, comparisons, and / or / not.Project: cinema ticket prices6 lessonsChapter 6Loops that countfor loops, range(), totals and counters.Project: a times-table tester6 lessonsChapter 7Loops that waitwhile loops, checking input, stopping with break.Project: guess the number6 lessonsChapter 8Working with textIndexes, slices, len(), string methods, looping through text.Project: a username maker and a Caesar cipher7 lessons
Chapter 9ListsMaking, changing and looping through lists; sum, max, in.Project: a class registerComing soon
Chapter 10Functionsdef, parameters, return values, local and global.Project: a dice gameComing soon
Chapter 11Finding and fixing bugsSyntax, logic and runtime errors, trace tables, test data.Project: fix the broken shopComing soon
Chapter 12FilesReading and writing text and CSV files.Project: a high-score tableComing soon
Chapter 13Dictionaries and tablesDictionaries, lists of lists, records.Project: a contact bookComing soon
Chapter 14Modules and drawingrandom, math, time, and turtle drawing.Project: a random quizComing soon
Chapter 15AlgorithmsSearching, sorting and recursion, written yourself.Project: a sort raceComing soon
Chapter 16Objects and classesClasses, attributes, methods, inheritance.Project: a virtual petComing soon
Chapter 17Bigger projectsPlanning a larger program, then building it step by step.Project: hangman, top trumps or a stock systemComing soon

Run it, don't just read it

Real Python runs in your browser. Press Run, see what happens, change it, run it again.

Step through

Run any program one line at a time and watch a trace table fill in, so you can see what your code really does.

Errors in plain English

Python's message, plus what it means and where to look. Hints open one at a time when you're stuck.