Your CMO wants a formatted spend summary for every campaign — clean enough to paste into the Monday standup email. In Excel, how do you start?
Campaign name in column A, spend in column B, and a formula in C that concatenates them with &" — $"&TEXT(B2,"0.00").
Python feels familiar. The & concatenation becomes an f-string, TEXT(B2,"0.00") becomes a format specifier. But first — the spend has to live somewhere. spend = 1250.0 is your column B cell: a variable, a name you give to a value so you can reference it later without re-typing. One = is assignment; two == is comparison.
So spend = 1250.0 just stores the number — it doesn't evaluate to true or false? I keep reading it as "spend equals 1250".
Correct — one = writes, two == reads. Once named, you combine variables with an f-string. Prefix the string with f, drop variables inside curly braces, and for a float add :.2f to pin exactly two decimal places:
name = "Email Blast"
spend = 1250.0
label = f"{name} — ${spend:.2f}" # Email Blast — $1250.00Oh — and the whole thing wraps into a function I can call for any campaign, not just Email Blast.
Named cells without the drag-and-drop grief. Write it once, run it a hundred times:
def format_campaign(name: str, spend: float) -> str:
result = f"{name} — ${spend:.2f}"
return resultI've spent years wrestling with TEXT() in Excel. This is embarrassingly straightforward by comparison.
That's the right reaction. Forget the f prefix and every {name} prints literally. Forget :.2f and 1250.0 stays 1250.0, no padding. Both are silent bugs — no error, wrong output, and they only surface when someone pastes the result into a slide deck.
A variable is a label attached to a value. spend = 1250.0 creates a float; name = "Email Blast" creates a str. Python infers the type — no declaration needed.
Prefix any string with f and embed variables inside {}. A spec after : controls numeric shape:
| Spec | Example | Output |
|---|---|---|
:.2f | f"{1250.0:.2f}" | 1250.00 |
:,.2f | f"{1250.0:,.2f}" | 1,250.00 |
:>5 | f"{7:>5}" | 7 |
f prefix — "{name}" prints the literal braces. Silent bug, no error.:.2f — 1250.0 renders as 1250.0, not 1250.00. Inconsistent output.= vs == — assignment vs. comparison.Your CMO wants a formatted spend summary for every campaign — clean enough to paste into the Monday standup email. In Excel, how do you start?
Campaign name in column A, spend in column B, and a formula in C that concatenates them with &" — $"&TEXT(B2,"0.00").
Python feels familiar. The & concatenation becomes an f-string, TEXT(B2,"0.00") becomes a format specifier. But first — the spend has to live somewhere. spend = 1250.0 is your column B cell: a variable, a name you give to a value so you can reference it later without re-typing. One = is assignment; two == is comparison.
So spend = 1250.0 just stores the number — it doesn't evaluate to true or false? I keep reading it as "spend equals 1250".
Correct — one = writes, two == reads. Once named, you combine variables with an f-string. Prefix the string with f, drop variables inside curly braces, and for a float add :.2f to pin exactly two decimal places:
name = "Email Blast"
spend = 1250.0
label = f"{name} — ${spend:.2f}" # Email Blast — $1250.00Oh — and the whole thing wraps into a function I can call for any campaign, not just Email Blast.
Named cells without the drag-and-drop grief. Write it once, run it a hundred times:
def format_campaign(name: str, spend: float) -> str:
result = f"{name} — ${spend:.2f}"
return resultI've spent years wrestling with TEXT() in Excel. This is embarrassingly straightforward by comparison.
That's the right reaction. Forget the f prefix and every {name} prints literally. Forget :.2f and 1250.0 stays 1250.0, no padding. Both are silent bugs — no error, wrong output, and they only surface when someone pastes the result into a slide deck.
A variable is a label attached to a value. spend = 1250.0 creates a float; name = "Email Blast" creates a str. Python infers the type — no declaration needed.
Prefix any string with f and embed variables inside {}. A spec after : controls numeric shape:
| Spec | Example | Output |
|---|---|---|
:.2f | f"{1250.0:.2f}" | 1250.00 |
:,.2f | f"{1250.0:,.2f}" | 1,250.00 |
:>5 | f"{7:>5}" | 7 |
f prefix — "{name}" prints the literal braces. Silent bug, no error.:.2f — 1250.0 renders as 1250.0, not 1250.00. Inconsistent output.= vs == — assignment vs. comparison.Harper manages paid campaigns across five channels and needs clean, formatted spend labels for the Monday standup email. Write `format_campaign(name, spend)` that returns a string like `"Email Blast — $1250.00"` using an f-string with `:.2f` formatting — for example, `format_campaign("Email Blast", 1250.0)` should return `"Email Blast — $1250.00"`.
Tap each step for scaffolded hints.
No blank-editor panic.