Prerequisites & Notation

Before You Begin

This chapter assumes you once knew Python reasonably well but may be rusty. If any of these items feel completely foreign (not just forgotten), review the linked material first.

  • Basic programming concepts: variables, loops, functions, conditionals

    Self-check: Can you write a function that takes a list and returns the sum of its elements?

  • Command-line usage: navigating directories, running scripts

    Self-check: Can you open a terminal, navigate to a directory, and run python script.py?

  • Basic Python syntax: indentation, imports, print statements

    Self-check: Can you write import math; print(math.sqrt(2)) without looking it up?

Notation for This Chapter

Symbols and conventions introduced in this chapter. Python-specific notation is used throughout the book.

SymbolMeaningIntroduced
venv`venv`Python virtual environment (isolated package namespace)s01
conda`conda`Cross-platform package and environment manager for scientific Pythons01
`__init__`, `__repr__`, etc.Dunder (double-underscore) methods — Python's object protocol hookss02
O(1)O(1), O(n)O(n), O(nlogn)O(n \log n)Time complexity of operations on data structuress03
yield`yield`Python keyword that turns a function into a generator (lazy iterator)s04
f"x:.2f"`f"{x:.2f}"`f-string with format spec — Python's preferred string interpolations05