This is a working Python, not a quiz about Python. Every lesson has a short explanation, a task, and an editor; you write real code, press Run, and CPython (compiled to WebAssembly) runs it right there in the tab and checks the result. The checks tell you what they expected and what they got, hints are one click away, and the solution is there when you want to compare.
The course goes from printing a line to writing classes, in the order the ideas build on each other: values and variables, decisions, loops, the four collection types, strings in depth, functions in depth, and errors and classes. It ends in a project, a text statistics report, that is not started from nothing: one lesson in each module builds one of its parts, saved in this browser as you go, and the project imports them as a module of your own. Forty lessons of ten minutes or so each; you can stop and pick up later.
What you will learn
- Variables, numbers, strings, and printing
- if, elif, else, and the match statement
- for and while loops
- Lists, dictionaries, tuples, and sets
- String methods, formatting, and regular expressions
- Functions with defaults, *args, lambdas, recursion, generators
- Exceptions, classes, inheritance
- A final project assembled from the parts you built
The final project
The course ends with Project: text statistics: a text statistics report assembled from your own functions. 8 of the lessons build a part of it, saved in this browser as you go, so the project is assembled from your own work rather than started from nothing.
PUNCTUATION(Variables) is the set of characters stripped from the ends of words before they are counted.word_kind(Functions) sorts a word into short, medium, or long, so the report can count each kind.count_vowels(for loops and range) counts the vowels in the raw text for one line of the report.longest_words(Sorting) picks the longest words for the report, longest first and alphabetical among ties.word_counts(Counting things) turns the list of words into a dictionary of word to count.clean_words(String methods) turns raw text into the list of lower-case words everything else counts.sentences(Generators) yields the sentences of a text one at a time, for the sentence count.Report(Classes) holds the numbers the project computes and prints the summary line.