Prologue — "The Second Signal"

Your first cell: Python right in the browser

15 min
What you'll learn
  • run Python right on the lesson page — nothing to install
  • create variables and read code line by line: line → what Python did → what is now in memory
  • print results with print
  • compute turnover, conversion and a remainder — and call each number by its honest name

The investigator's tool

SQL pulls data out of a database. Python helps with everything else: gluing tables together, computing metrics, drawing charts, hunting anomalies. SQL can do some of this too — the tools overlap, and that is fine.

Here Python runs right in the browser: the same machine that opened this page executes your code. Nothing to install, nothing to break.

"A bear has moved into my archive. A panda, to be precise. Get used to her — she will be fetching your tables. But not today." — QUERY

A cadet runs a cell on the console while a hologram shows three commands executing in sequence, changing memory, and producing a result.
Code is read by a single scheme: the line → what Python did → what changed in memory → what got printed.

This lesson takes three things as its foundation: variables, arithmetic and print. Everything else — lists, loops, how functions work — waits for chapter 2, and not before these three feel ordinary.

We will read code by one scheme, worth memorizing:

line of code → what Python did → what is now in memory → what got printed

Start with a three-line cell. Press Run.

Example 1 of 5. Run it as is.
python · pandas

What happened, line by line

Python executes code top to bottom, one line at a time: it reads a line, does what it says, moves on.

Line 1: orders = 1284

  • what Python did: put the number 1284 in memory and hung the label orders on it;
  • what is now in memory: orders → 1284;
  • what got printed: nothing. Assignment is silent — the first thing that surprises beginners.

The = sign here is not mathematical equality. Read it as an arrow right to left: "take the value on the right and remember it under the name on the left". A name with a value is called a variable.

Line 2: print(orders)

  • what Python did: looked at what lies under the label orders and printed it;
  • what is now in memory: unchanged — print only reads;
  • what got printed: 1284.

Line 3: print('Orders on March 14:', orders)

  • what Python did: printed two values separated by a space — first the quoted text, then the variable's value;
  • what got printed: Orders on March 14: 1284.

About the quotes: quoted text is something Python does not try to understand, it prints it literally. So print(orders) prints 1284, while print('orders') would print the word orders. That is exactly the day-one mistake everyone makes.

print is the output command: everything passed inside the parentheses, comma-separated, lands on screen separated by spaces. Strictly it is a function, and what a function is comes in chapter 2; for now treat it as a "show me" button.

And last: memory lives until the end of the cell. The variable from line 1 is available on every line below — every calculation rests on that.

A variable is a name for a memory cellcodePython memoryorders = 1284avg_check = 730revenue = orders * avg_checkorders1284avg_check730revenue937320on line 3 Python substitutes the values: 1284 × 730name → value; “=” means “put it into the cell”
Python's memory is a table of labels: name on the left, value on the right. Assignment writes a row; print only reads it.
Example 2. What happens if you assign a variable a new value?
python · pandas

A variable is a label, not a box

The second assignment did not create a second variable. It moved the label orders onto a new number:

after line 1:   orders → 1284
after line 4:   orders → 1301     (the old value is gone)

The old value disappears without a trace — if you still need it, you had to keep it under a different name: orders_yesterday = 1284, orders_today = 1301.

That is why variable names matter more than they seem on day one: a, b, x1 will baffle even their author a week later, while orders_today reads itself. The rules in this course are simple: Latin letters, digits and underscores, never start with a digit, no spaces — hence avg_check, not avg check.

Now let us compute something meaningful — on an example where it is easy to lie to yourself.

Turnover is not revenue

The average check is the average amount of one order. Multiply it by the number of orders:

1284 orders × 730 ₽ = 937,320 ₽

What is that number? The temptation to call it "revenue" is enormous — and it is the course's first terminology trap.

937,320 ₽ is turnover, also known as GMV (gross merchandise value): the total value of all orders that passed through the platform. Buyers did pay that money — but they paid it to the sellers, not to Kotomarket.

Kotomarket is a marketplace: it does not own the food and the beds, it matches sellers with buyers. Its own money is the commission on each order, plus ad and paid-delivery income. At a 12% commission the platform's revenue for that day is:

937,320 ₽ × 0.12 ≈ 112,478 ₽

Nearly an eightfold gap. Mixing these numbers up in a report is not a slip of the tongue — it is a different business.

NumberWhat it meansOn our day
Turnover (GMV)what buyers paid for goods937,320 ₽
Marketplace revenuewhat the platform got out of it (commission)≈ 112,478 ₽
Profitwhat is left after all costssmaller still, and a separate conversation

For an ordinary shop selling its own goods, turnover and revenue coincide — no confusion there. It appears exactly where an intermediary appears: a marketplace, a ride aggregator, a delivery service.

L., entry #8: "The board was shown a slide reading 'revenue 2.3M a day'. That was GMV. The commission is 280 thousand, and the whole company lives on it. Nobody corrected it. I did. I was asked not to spoil the mood."

Example 3. Turnover and the platform's revenue. Run it, then change the commission from 0.12 to 0.05 and watch the second line move.
python · pandas

Arithmetic and comments

Comments. Everything after # to the end of the line is skipped by Python — a note for humans. In commission_rate = 0.12 # platform commission, 12% the variable names the number and the comment names the unit. Both labels are free and both save you a month later.

Arithmetic. Four signs cover nearly everything an analyst needs:

SignOperationExample
*multiply1284 * 730937320
/divide75 / 10000.075
+add1284 + 171301
-subtract200 - 17183

Precedence is the ordinary school one: * and / first, then + and -, parentheses above all. (1412 - 41) * 695 and 1412 - 41 * 695 are two very different numbers.

Computation inside an assignment. The line gmv = orders * avg_check runs in two beats: Python first computes the right-hand expression (1284 * 730937320) and only then hangs the label gmv on the result. What sits in memory afterwards is a number, not a formula: change orders later and gmv will not recompute itself.

round(...) rounds to a whole number: round(112478.4)112478.

Example 4. A share in percent — 75 of 1000 visitors bought.
python · pandas
Example 5. A remainder — how many parcels arrived.
python · pandas

Three patterns you already know

Five cells — and you hold three calculations that half of analytics is built from:

product:     gmv = orders * avg_check                'how much in total'
share:       conversion = buyers / visitors * 100    'what fraction'
remainder:   delivered = shipped - lost              'how many are left'

In chapter 1 the same three formulas apply to DAU, funnels and — only the variable names change.

Now the assignments. They work like this: you finish the code in the cell and press the button — the system runs your code and checks the result, and if it does not add up it tells you what is off. Being wrong is fine: unlimited attempts, and a hint is right there.

Practice: write the code
L.'s journal for March 15: 1412 orders, average check 695 ₽. Replace the 0 stub with a formula and compute the day's turnover (GMV) into the variable gmv.
python · pandas
Practice: write the code
The full March 15 report. Known: 1412 orders, average check 695 ₽, platform commission 11%, and 20,400 people opened the app that day; assume that each order was placed by a different visitor. Compute three numbers:
  • gmv — the day's turnover;
  • revenue — Kotomarket's revenue (the commission on turnover);
  • conversion — order conversion, in percent.
Replace the stubs in the code with your own formulas.
python · pandas
Check yourself
A marketplace had 1284 orders at an average check of 730 ₽ in a day. What is the right name for the number 937,320 ₽?
Key takeaways
  • Python here runs right in the browser — nothing to install
  • Python reads code top to bottom; name = value puts a value in memory under a label, a second assignment moves the label
  • assignment is silent, print(...) prints; quoted text prints literally, an unquoted name prints its value
  • # starts a comment; in an assignment the right-hand side is computed first, then the result lands in the variable
  • three calculation patterns: product ("how much in total"), share ("what fraction"), remainder ("how many are left")
  • turnover (GMV) = orders × average check is the buyers' money; a marketplace's revenue is the commission on that turnover, and it is many times smaller

The prologue is closed. Next — chapter 1: DAU, funnels, , and the first case from L.'s journal.