Python
25 lessons from your first print to functions, collections, files, JSON, classes and testing, with visuals, exercises and a grade-report project.
Every chapter is an island. Finish its lessons, beat its challenge, and sail on ⛵
Island 1
Getting started
- Your first Python programWhat Python is used for, print, and comments.6 min3 🎮
- Variables and typesStore values and check their type with type().8 min3 🎮
- Numbers and operatorsTrue and floor division, remainder, powers and round.7 min3 🎮
- Type conversion and inputint, float and str, and why input always returns text.7 min3 🎮
Island 2
Strings
- Strings and f-stringsPut variables inside text, plus handy string tools.6 min3 🎮
- String indexing and slicingSelect characters and slices, including their boundaries.8 min3 🎮
- Cleaning and splitting stringsstrip, split, join, searching and replacement.8 min2 🎮
Island 3
Control flow
- Conditions: if, elif and elseIn Python indentation isn't style; it's part of the code.7 min3 🎮
- Loops: for and whilerange, and looping over things.8 min3 🎮
- Loop control and nestingStop a search, skip an item and nest loops.8 min2 🎮
Island 4
Functions
- Functions with defWrite code once, use it many times.8 min3 🎮
- Parameters and scopeDefaults, keyword arguments and local variables.8 min2 🎮
Island 5
Collections
- ListsA list of values: add, remove and loop.8 min3 🎮
- DictionariesKeys and values: a small lookup table.7 min2 🎮
- Tuples and setsFixed sequences and collections of unique values.8 min2 🎮
- Comprehensions, enumerate and zipTransform, filter and pair collections.8 min2 🎮
Island 6
Errors, files and libraries
- Handling exceptionstry, except, else and finally without hiding errors.8 min2 🎮
- Modules and the standard libraryImport existing tools and organize files.8 min2 🎮
- Reading and writing fileswith, encoding and file lifetime.8 min2 🎮
- Exchanging data with JSONConvert JSON strings to dictionaries and back.8 min2 🎮