Python Programming Series

Learning Python, from first principles

A ten-part guide covering the language from literals and variables through object-oriented programming, exception handling, and file I/O. Every article is paired with a Jupyter notebook containing the runnable code.


The ten articles

  1. 01 Introduction to Python Literals, variables, syntax rules, keywords and identifiers, then a level deeper into what actually happens in memory when your code runs. Notebook ↗
  2. 02 Lists, Tuples and Strings Creating, indexing and slicing; what mutability really means; copying pitfalls; and the methods you will reach for most often. Notebook ↗
  3. 03 Sets and Dictionaries Uniqueness and set mathematics, key-value lookups, and how to choose between the two when both would technically work. Notebook ↗
  4. 04 Operators All six families, the is versus == distinction explained properly, bitwise operators bit by bit, and operator precedence. Notebook ↗
  5. 05 Conditional Statements and Loops if / elif / else, while and for, break, continue and pass, and list comprehension as a shorter way to say the same thing. Notebook ↗
  6. 06 Functions in Python Definition versus call, parameters versus arguments, the four argument types, return versus print, and variable scope. Notebook ↗
  7. 07 Types of Functions in Python enumerate, zip, filter, map and reduce; lambda expressions; recursion; and the higher-order functions that tie them together. Notebook ↗
  8. 08 Object-Oriented Programming Classes and objects, and the four pillars: encapsulation, inheritance, polymorphism and abstraction, each with a worked example. Notebook ↗
  9. 09 Exception Handling try / except / else / finally, the exception hierarchy, raising and re-raising, assert, and building your own exception types. Notebook ↗
  10. 10 File Handling Opening, reading and writing; file modes; seek and tell; the os module and pathlib; CSV and JSON; and handling file errors gracefully. Notebook ↗
New here? Start with Introduction to Python and work through in order — each article assumes the ones before it. All the code lives in the GitHub repository.