A research notebook can produce the wrong result if cells run in an unexpected order. This lesson explains when to use a notebook, a script or a module. It shows how to keep a reusable calculation function separate from the code that prints a report. A fresh run and tests check that the result does not depend on hidden state.
Learning objectives. By the end of this note you should be able to choose a notebook or script, recognise hidden notebook state, and structure a script with a
main entry point.In this lesson
- Choose by purpose
- Remove hidden notebook state
Before you start
The full lesson, with worked examples and exercise solutions, is for members.
Read the full lessonNew to SelfMadeQuant.com? See membership options or browse the Python and Data Primer syllabus.