The Analyst's Path

Phase 12 · Finance Plus, AI and the quant-code track · free

Programming from Zero — Python I

CS1.01 · 13,489 words

Every analyst already runs programs. A spreadsheet formula is a tiny program; a set of filter-and-sort clicks is a program you re-perform by hand every single time, forgetting a step here and there, and calling the result "the model." The difference between…

Learning objectives

By the end you can:

  1. Explain, in plain language, what a program is and what the Python interpreter actually does with your code (read it, translate it, and execute it one instruction at a time) and distinguish a statement (an instruction) from an expression (something that produces a value).
  2. Name Python's core built-in types (int, float, str, bool, and NoneType) recognize a literal of each, and predict what type(x) returns for any value you can construct.
  3. Explain what a variable actually is in Python (a name bound to a value, not a labeled box that contains it), predict the effect of assignment and re-assignment, and trace multiple-assignment and swap idioms correctly.
  4. Evaluate arithmetic, comparison, and logical expressions by hand, including operator precedence, integer vs. true division (// vs /), the modulo operator (%), and augmented assignment (+= and friends).
  5. Build and reason about strings: concatenation, f-strings with format specifiers (:.2f and friends), and the handful of string methods (.strip(), .split(), .upper()/.lower()) needed to clean and format real data.
  6. Use a Python list as an ordered sequence of values well enough to index it (including negative indices), measure it with len(), grow it with .append(), and iterate over it, while knowing this is a first taste, not the full picture (CS1.02 owns the deep list/tuple/dict/set comparison).
  7. Write and trace control flow (if/elif/else for decisions, while for open-ended repetition, for for repetition over a known sequence) and correctly predict the output of nested and combined control-flow code.
  8. Write functions: parameters, a return value, the difference between return and print, and the basic scoping rule that a name assigned inside a function is local to it, and explain why breaking a program into small, well-named functions is not decoration but the single highest-leverage habit in this entire module.
  9. Perform basic input/output: format and print numbers precisely with f-strings, read a value with input(), and (critically) remember that everything read from input() or a text file arrives as a str and must be deliberately converted before it can be used as a number.
  10. Apply everything above to the module's running problem: given a list of daily closing prices from an Indian (₹, NSE-style) or US (\$, NYSE-style) snapshot, compute the price change, the total return, the count of up-days, the average daily change, and the best/worst single day, first by hand, then in real, running, tested Python (this module's code pack, CS1.01).
  11. (Productivity objective: R10 duality.) Use an AI coding assistant as a copilot for exactly the parts of this module you already understand by hand, scaffolding, boilerplate, explaining an unfamiliar error message, while never letting it write code whose logic you cannot personally verify, and while always running the tests yourself before trusting the result.

The duality, stated once (R10). Objectives 1–10 are the understanding objective: the gate (quiz ≥ 85%, code-pack ≥ 85% with hidden tests green) rewards being able to trace, write, and debug this code yourself, by hand and in the editor. Objective 11 is the productivity objective: knowing how a real developer uses an AI copilot on top of that understanding, never instead of it. A copilot can type faster than you. It cannot pass this module's hidden tests for you, because passing them requires code that is actually correct on inputs the copilot, and you: have never seen.


Prerequisites & connections

Builds on. Nothing. This is the first node of the quant-cs branch and, per the program's day-one entry rule, it unlocks from the very start, no finance-phase progress and no other branch is required. The only assumptions are comfort with ordinary arithmetic (addition, subtraction, multiplication, division, percentages) and the patience to be pedantic, because a computer executes exactly what you wrote, not what you meant. If you have never written a line of code before, you are exactly the intended reader.

This page is an excerpt

The full module runs to 13,489 words and carries the worked examples, the tables, the quiz that gates the next module and the spaced-repetition deck built from it. All of it is free and none of it needs an account.