1. Part 1

    Post

    What is Python, and why use it?

    What Python is, what it's good for, and how it differs from languages like C and Java: interpreted, dynamically typed, indentation-based and batteries included.

  2. Part 2

    Post

    print(): showing output in Python

    How print() works in Python 3: printing several values, the sep and end arguments, printing to stderr, and the common mistake of printing None.

  3. Part 3

    Post

    Variables and types in Python

    How variables work in Python: assignment, names, the basic types int, float, str, bool and None, type(), and the NameError.

  4. Part 4
  5. Part 5

    Post

    f-strings: formatting text in Python

    How f-strings work in Python: putting expressions in braces, format specs for width, alignment, precision, thousands separators and percentages, the = debug specifier, and !r conversions.

  6. Part 6

    Post

    Number operations in Python

    The arithmetic operators in Python: + - * / // % and **, the difference between true and floor division, round, the math module, and why floats aren't exact.

  7. Part 7

    Post

    Type conversion in Python

    How to convert between Python types with int(), float(), str(), bool(), list(), tuple() and set(): what each conversion does, truncation, bases, truthiness, and the errors when a conversion fails.

  8. Part 8

    Post

    input(): reading text from the user

    How input() reads a line from the user in Python: the prompt, why the result is always a str, converting it with int() and float(), the ValueError on bad input, and EOFError.

  9. Part 9

    Post

    The date type in Python

    How to work with dates in Python using datetime.date: creating dates, reading parts of a date, formatting with strftime and isoformat, date arithmetic with timedelta, and invalid dates.

  10. Part 10

    Post

    Lists in Python

    A list holds many values in order. Creating one, indexing and slicing, adding and removing items, sorting, copying without surprises, and a word on tuples.

  11. Part 11

    Post

    if, elif, else: conditions in Python

    How Python decides which code to run: if, else and elif, the comparison operators, truthy and falsy values, the conditional expression (x if C else y), and a first look at match.

  12. Part 12
  13. Part 13
  14. Part 14

    Post

    The modulo operator % in Python

    What % does in Python and where it's useful: even or odd, every Nth item, wrapping around a list or a clock, splitting seconds with divmod, digits, FizzBuzz, and how it treats negative numbers.

  15. Part 15

    Post

    Loops in Python: for and while

    Running code again and again: for over a list or a range, enumerate and zip, while, break and continue, the else clause on a loop, and the loop bugs everyone writes once.

  16. Part 16

    Post

    Dictionaries in Python

    A dict stores values by key instead of by position. Creating one, reading safely with get, adding and removing, looping over keys and values, counting, nesting, and the keys you can use.

  17. Part 17

    Post

    Functions in Python

    def, parameters and return values, default and keyword arguments, the mutable default trap, docstrings and type hints, and passing a function as a value.

  18. Part 18

    Post

    Code blocks and scope in Python

    What a code block is in Python, why if, for, while and try don't create a new scope, which blocks do (functions, classes, comprehensions), and the bugs that come from mixing them up.

  19. Part 19
  20. Part 20

    Post

    TypeError and type checking in Python

    The common TypeError messages in Python and what they mean, checking types with type() and isinstance(), why type hints are not enforced, and when to check types versus catching the error.

  21. Part 21
  22. Part 22

    Post

    pip: installing packages in Python

    How pip installs third-party packages from PyPI: install, pin versions, list, show, freeze into requirements.txt, uninstall, and why to use a virtual environment with python -m pip.

  23. Part 23