Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Start Here: Part I Guide — Foundations for Scientific Programming

Scientific Computing with Python

Part I develops the habits that make a scientific calculation inspectable: know which interpreter ran it, state numerical assumptions, make algorithmic logic explicit, choose data structures deliberately, and give reusable code a clear contract.

How to use this part

Read the numbered chapters in order on a first pass. Their examples differ, but they share one habit: make an assumption visible, inspect what the program actually did, and revise the claim when the evidence demands it. Deep Dive and Reference sections preserve useful detail for the moment when you have a concrete need; they are not a second hidden prerequisite sequence.

First reading

Read Chapter 1 through Chapter 6 in order. Chapter 6 completes the first pass by asking when shared state and behavior need an explicit boundary; that question returns in Part II when Chapter 10 develops small scientific types.

ChapterCentral questionReturn when…
1. Computational environmentsWhich Python and package versions produced this result?an import, version, or notebook result differs between machines
2. Python as a scientific calculatorWhat numerical claim can this computation support?a value rounds oddly, overflows, or fails an equality check
3. Control flow and logicWhat precisely makes this algorithm stop or choose a path?a loop does not terminate or a condition silently skips cases
4. Data structuresWhat access pattern does this data representation promise?mutation, lookup, or scaling behavior is surprising
5. Functions and modulesWhat does this computation promise about inputs, outputs, and failure?code is duplicated or a result’s assumptions are unclear
6. Small scientific objectsDoes state belong with the operations that maintain it?related values travel together and invariants are being lost

Return visit

Use the chapters diagnostically rather than memorizing them. A result that changes across machines belongs in Chapter 1; an uncertain tolerance belongs in Chapter 2; a non-terminating loop belongs in Chapter 3; an unexpectedly slow lookup belongs in Chapter 4; and a computation with unclear assumptions belongs in Chapter 5. Related values whose meaning or invariants drift apart belong in Chapter 6.

The throughline: defensive scientific programming

Computational science fails as often from structure as from syntax: an environment drifts, hidden state changes an analysis, a numerical assumption is unstated, or a data representation does not match the question. These chapters treat code as an instrument for reasoning.

These are computational-science habits, not Python trivia. They make work portable across scientific domains: a transit-depth calculation, a climate model, an image-processing pipeline, or a laboratory calibration all need an environment record, named quantities, explicit stopping rules, and interpretable code.

Core habits to carry forward

HabitWhat it protectsWhere to build it
Reproducible environmentsaccidental interpreter and dependency driftChapter 1
Numerical honestyunsupported precision and fragile comparisonsChapter 2
Explicit control flowhidden branches and unbounded iterationChapter 3
Scaling intuitioninappropriate lookup and mutation patternsChapter 4
Function contractsambiguous inputs, units, and failure modesChapter 5
Useful stateinvalid or disconnected scientific entitiesChapter 6

Next connection

Finish the first pass with Part I Recap — Trustworthy Scientific Programming. Then continue to Part II: Arrays, Visualization, and Reliable Computing, where the same reliability habits become tools for inspecting arrays, figures, numerical behavior, and small scientific types.