Skip to content
Python for Quantitative Finance / Control Flow and Simple Numerical Programs

Overview

Python Foundations gave every value a type and every expression a rule for producing one. A program built from expressions alone can only ever compute a single, fixed thing — the same code, the same output, every time it runs. Control flow is what turns a fixed expression into a program that behaves differently depending on the data it sees, and repeats work without the programmer writing that work out by hand. This topic builds the two control-flow constructs Python offers — branching (if/elif/else) and iteration (while, for) — and then spends its second half on the topic's payoff: three numerical root-finding algorithms (exhaustive enumeration, bisection search, Newton–Raphson) that only exist because a program can loop. These three methods are not a digression from control flow — they are the first substantial demonstration of why it matters, and they are the direct ancestors of every implied-volatility solver, calibration routine, and iterative numerical method that appears later in this vault.

In this lesson

  1. Learning objectives
  2. Contents
  3. The big picture

The full lesson is for members.

Read the full lesson

New to SelfMadeQuant.com? See membership options or browse the Python for Quantitative Finance syllabus.