Programming with Python
Python analysis code depends on choices about types, mutation, array axes, and missing values. These sixteen lessons explain those choices with small bioinformatics examples that you can run as scripts.
Choose a route
Section titled “Choose a route”| Starting point | Route |
|---|---|
| You are new to Python. | Set up a project with Packages, then follow the lesson order below. |
| You write analysis scripts. | Review Functions, Iterators, NumPy, and the table library you use. Apply testing and packaging in Files and command-line programs. |
| You are preparing for an interview. | Refresh data structures, control flow, functions, and classes. Continue with Python interview preparation for algorithms and complexity. |
The Python lessons use Python 3.13. Each library lesson gives its dependency
instructions. Save examples in a file and run them with uv run python as
described in the packages lesson. Follow each lesson’s order when later examples
use an object created earlier.
Lesson order
Section titled “Lesson order”| Order | Lesson | What you should explain afterward | Video and captions |
|---|---|---|---|
| 1 | Variables and data types | How do types, conversion, and missing values affect an expression? | No video. |
| 2 | Data structures | When do a list, tuple, dictionary, or set fit the data? | Watch and captions. |
| 3 | Control flow | Which condition controls each branch and loop? | No video. |
| 4 | Functions | What does a function accept, return, and reject? | Watch and captions. |
| 5 | Classes | Which data and behavior belong together, and which axis stores each sample? | Watch and captions. |
| 6 | Type annotations | What can a static checker detect before execution? | No video. |
| 7 | Iterators and generators | When does a stream produce a value, raise an error, or become exhausted? | No video. |
| 8 | Debugging | How do you distinguish an exception from a plausible but incorrect result? | No video. |
| 9 | Testing | Which test rejects an incorrect formula or an invalid input? | No video. |
| 10 | Documentation and style | How do you document a function and build its API reference? | No video. |
| 11 | Packages | How do you reproduce a project’s dependencies from its lockfile? | No video. |
| 12 | Create a package | How do you document, test, build, and install your own package outside its source directory? | No video. |
| 13 | Files and command-line programs | How do file validation, arguments, output protection, and tests work together? | No video. |
| 14 | NumPy | How do shape, broadcasting, and copies change an array operation? | Watch and captions. |
| 15 | pandas | How do labels, merge keys, and assignment rules affect a table result? | No video. |
| 16 | Polars | How do expressions and lazy queries change table operations? | No video. |
Refresh before an interview
Section titled “Refresh before an interview”Explain whether a function changes its input before you discuss its result. Distinguish a new list from another reference to the same list. Check whether a dictionary lookup, list slice, or sort contributes to the cost of a loop. The complexity lesson connects these Python operations to time and auxiliary space.
The interview course covers nineteen algorithm lessons, including graph dependencies, connected components, greedy choices, and two-dimensional dynamic programming. Its practice plan distinguishes repeat exercises from problems with changed requirements. Use the mixed practice statements to select a method without a lesson title as a clue.
Further reading
Section titled “Further reading”The Python 3.13 tutorial explains the language and standard library. Consult its relevant chapter when you need more examples of a language feature.
Each lesson links the documentation for its methods and libraries. The interview course supplies algorithm references and downloadable scripts for its worked examples.