Simple Python

Python for people who have never programmed. It runs real Python in the page, and when Python stops with an error, the lesson explains the message in plain words.

Each lesson lists the sources it follows, mostly the official Python documentation. See all sources.

Last updated

PThe capstone: A simple library management system: books, members, loans, returns, fines and search, saved between runs.

Stage 1: Basics

Write small programs that calculate, decide and repeat.

  1. 1.1Your first program Open
  2. 1.2Printing things Open
  3. 1.3Variables Open
  4. 1.4Numbers Open
  5. 1.5Text and input Open
  6. 1.6Making decisions Open
  7. 1.7Repeating things Open
  8. 1.8Functions Open
  9. 1.9Lists and tuples Open
  10. 1.PProject: overdue fines Open

Stage 2: Bigger programs

Organise data, handle things that go wrong, split code into files and prove it works.

  1. 2.1Lists in depth Open
  2. 2.2Dictionaries Open
  3. 2.3Sets, and choosing a collection Open
  4. 2.4Comprehensions Open
  5. 2.5Functions, more Open
  6. 2.6When things go wrong Open
  7. 2.7Modules and the standard library Open
  8. 2.8Files, CSV and JSON Open
  9. 2.9Python on your computer Open
  10. 2.10Testing Open
  11. 2.11Type hints Open
  12. 2.PProject: catalogue search Open

Stage 3: Classes and objects

Write classes and use objects with confidence: the groundwork for object-oriented programming.

  1. 3.1Everything is an object Open
  2. 3.2Your first class Open
  3. 3.3Objects working together Open
  4. 3.4Class attributes, class methods and static methods Open
  5. 3.5Printing and comparing objects Open
  6. 3.6Dataclasses Open
  7. 3.PProject: book cards Open

Stage 4: Object-oriented programming

Encapsulation, inheritance, polymorphism and abstraction: how Python does each one, and how that differs from Java, C# and Rust.

  1. 4.1The four ideas of OOP Open
  2. 4.2Encapsulation: public, "protected" and "private" Open
  3. 4.3Encapsulation: getters and setters Open
  4. 4.4Encapsulation: keeping objects valid Open
  5. 4.5Inheritance: subclasses Open
  6. 4.6Inheritance: overriding and extending Open
  7. 4.7Inheritance: multiple parents and the MRO Open
  8. 4.8Inheritance: exception families Open
  9. 4.9Polymorphism through overriding Open
  10. 4.10Polymorphism: duck typing Open
  11. 4.11Polymorphism: operators and the data model Open
  12. 4.12Polymorphism: one name, different arguments Open
  13. 4.13Abstraction: abstract base classes Open
  14. 4.14Abstraction: protocols Open
  15. 4.15Composition over inheritance Open
  16. 4.16Design patterns, the Python way Open
  17. 4.PProject: the loan desk Open

Capstone

A library management system on your own computer: items, members, loans, fines, search and saving.

  1. C.1Plan and set up Open
  2. C.2The items Open
  3. C.3Members Open
  4. C.4Loans and returns Open
  5. C.5The catalogue and search Open
  6. C.6Saving and loading Open
  7. C.7The menu Open
  8. C.8Reports Open
  9. C.9Tests and finish Open

Extra module T: tkinter and CustomTkinter

Optional. A desktop window for the library, first with tkinter, which comes with Python, then with CustomTkinter for a modern look.

  1. T.1Your first window Open
  2. T.2The window is a class Open
  3. T.3Layout with grid Open
  4. T.4A presenter between the window and the library Open
  5. T.5Live values and tables Open
  6. T.6Events, refusals and closing Open
  7. T.7A modern look with CustomTkinter Open
  8. T.PProject: the library window Open

Extra module F: Flet

Optional. A modern app for the library with Flet, built from controls that are dataclasses, running on the desktop or in a browser.

  1. F.1Your first Flet app Open
  2. F.2Controls are objects Open
  3. F.3A presenter between the app and the library Open
  4. F.4Your own controls Open
  5. F.5Tables, dialogs and slow work Open
  6. F.PProject: the library app Open