Your First Cell: Python in the Browser
An Investigator's Tool
SQL pulls data from a database. Python helps you work with that data: combine tables, calculate metrics, draw charts, and find anomalies. SQL can do some of these things too — the tools overlap, and that's normal.
Here, Python runs right in your browser: the code executes on the same machine where this page is open. You don't need to install anything.
There's a bear in my archive now. A panda, to be precise. Get used to it — it'll be carrying tables around for you. Just not today. — QUERY

In this lesson, we'll focus on three things: variables, arithmetic, and print. Everything else — lists, loops, and how functions work — comes in Chapter 2, after these three have become familiar.
We'll use one pattern to read code. It's worth remembering:
line of code → what Python did → what changed in memory → what got printed
Start with a three-line cell. Click Run.
What Happened, Line by Line
Python executes this code from top to bottom, one line at a time: first the first line, then the second, then the third.
Line 1: orders = 1284
- what Python did: stored the number
1284under the nameorders; - what changed in memory:
orders → 1284; - what got printed: nothing. Assignment by itself doesn't display anything on the screen.
The = sign here does not mean mathematical equality. Read it as: “take the value on the right and store it under the name on the left.” A name associated with a value this way is called a variable.
Line 2: print(orders)
- what Python did: looked up the value currently associated with
ordersand passed it toprint; - what changed in memory: nothing —
printonly reads the value; - what got printed:
1284.
Line 3: print('Orders on March 14:', orders)
- what Python did: passed two values to
print— first the text in quotes, then the value of the variable; - what got printed:
Orders on March 14: 1284.
When you pass several values to print separated by commas, Python puts a space between them by default.
About quotes: Python treats text inside quotes as a text value, not as a variable name. That's why print(orders) prints 1284, while print('orders') would print the word orders. Without quotes, Python looks up the variable's value; inside quotes, it uses the text itself.
print is an output command: it displays whatever you pass inside its parentheses. Strictly speaking, it's a function; we'll cover functions in Chapter 2. For now, think of it as a “show me this” button.
One last point: a variable created on the first line is available to every later line in the same run. You can save the input data first, then use it below in calculations and when displaying the result.
print reads the value and displays it on the screen.A Variable Is a Label, Not a Box
The second assignment didn't create a second variable. It moved the label orders to a new number:
after line 1: orders → 1284
after line 4: orders → 1301 (old value is lost)
After that, you can no longer access the old value 1284 through orders. If you still need it, save it under another name first: orders_yesterday = 1284, orders_today = 1301.
That's why variable names matter more than they may seem on day one: a week later, even the author may not remember what a, b, or x1 meant, while orders_today is self-explanatory. The rules in this course are simple: use Latin letters, digits, and underscores; a name can't start with a digit; and spaces aren't allowed — so write avg_check, not avg check.
Now we'll calculate something meaningful, using an example where it's easy to misread the result.
GMV Is Not Revenue
Average order value (AOV) is the average amount of one order. Multiply it by the number of orders:
1284 orders × $7.30 = $9,373.20
What does that number represent? It's tempting to call it “revenue,” which leads straight into the first terminology trap in this course.
$9,373.20 is gross merchandise value, or GMV: the total value of the goods in orders that passed through the platform. That doesn't mean all $9,373.20 became Kotomarket's revenue: most of the value of those goods belongs to the sellers.
Kotomarket is a marketplace: it doesn't own the food and pet beds; it connects sellers with buyers. Its own revenue can come from order commissions, advertising, paid delivery, and other services. In our simplified example, we'll count only the commission. At a 12% rate, the commission revenue for the day is:
$9,373.20 × 0.12 ≈ $1,124.78
GMV is about 8.3 times larger than commission revenue. Mixing these numbers up in a report changes the meaning of the metric.
| Number | What it means | In our day |
|---|---|---|
| GMV | value of the goods in orders | $9,373.20 |
| Commission revenue | what the platform receives at a 12% commission rate | ≈ $1,125 |
| Profit | what remains from revenue after expenses | even less, and that's a separate discussion |
For a regular store that sells its own goods, the value of the goods sold usually counts toward its revenue in full. For a marketplace acting as an intermediary, GMV and the platform's own revenue are separate metrics.
L., entry #8: At the board meeting, they showed a slide saying “revenue $23,000 per day.” It was GMV. The commission was $2,800, and that's what the whole company lives on. Nobody corrected it. I did. They asked me not to ruin the mood.
Arithmetic and Comments
Comments. Python ignores everything after # through the end of the line — it's a note for humans. In commission_rate = 0.12 # marketplace commission, 12%, the variable name tells you that the value is a commission rate, while the comment explains how to read 0.12: it means 12%. Both labels are free, and both can save you time a month later.
Arithmetic. Four operators cover almost everything an analyst needs:
| Symbol | Operation | Example |
|---|---|---|
* | multiplication | 1284 * 7.30 → 9373.2 |
/ | division | 75 / 1000 → 0.075 |
+ | addition | 1284 + 17 → 1301 |
- | subtraction | 200 - 17 → 183 |
The order of operations is the same as in school: * and / first, then + and -; parentheses take priority over everything else. (1412 - 41) * 6.95 and 1412 - 41 * 6.95 produce two very different numbers.
Calculations inside assignments. The line gmv = orders * avg_check works in two steps: Python first calculates the expression on the right (1284 * 7.30 → 9373.2) and only then attaches the label gmv to the result. After that line, gmv stores the calculated number, not the formula: if you change orders afterward, gmv won't recalculate automatically.
round(...) rounds a number to the nearest integer: round(1124.784) → 1125.
Three Patterns You Already Know
After five cells, you already know three basic calculation patterns:
product: gmv = orders * avg_check 'how much in total'
share: conversion = buyers / visitors * 100 'what fraction'
remainder: delivered = shipped - lost 'how much is left'
You'll use these same operations several more times in Chapter 1 when calculating metrics — only the variables and the meaning of the numbers will change.
Now for the exercises. Here's how they work: complete the code in the cell and click the button. The system will run your code and check the result; if it doesn't match, you'll see exactly what's wrong. You can try as many times as you need, and there's a hint next to the task.
0 placeholder with a formula and calculate the day's GMV in the variable gmv.gmv— GMV for the day;revenue— Kotomarket's revenue (commission on GMV);conversion— conversion to an order, as a percentage.
Key takeaways
- Python runs right in the browser here — there's nothing to install
- Python reads code from top to bottom;
name = valuestores a value in memory under a label, and assigning again moves that label to a new value - assignment is silent, while
print(...)displays output; text in quotes is printed literally, while a name without quotes is replaced by its value #starts a comment; in an assignment, Python calculates the right-hand side first, then stores the result in the variable- three calculation patterns: product (“how much in total”), share (“what fraction”), and remainder (“how much is left”)
- GMV = orders × average order value — that's customers' money; marketplace revenue is the commission on GMV, and it's several times smaller
The prologue is complete. Next is Chapter 1: DAU, the , , and the first case from L.'s log.