Cost
Python Cost Interview Questions
Cost in an AI product is mostly settled before a model runs at all: which model the request goes to, how much of the conversation travels with it, and whether the same question gets paid for twice. These questions are the arithmetic behind those decisions. Prices are quoted per thousand tokens, separately for what you send and what comes back, and the context window has to hold both of them at once.
What cost questions ask you to do
Across the questions here, these are the shapes that come up:
- Pick the cheapest model that can still hold a request
- Price a conversation from its token counts
- Keep a running spend under a cap
- Decide when a long prompt earns a larger context window
- Work out what caching repeated prompts saves
Common mistakes with cost
Pricing the prompt and forgetting the answer, when output usually costs several times what input does and is the half you cannot predict. The other is measuring a prompt against a context window without leaving room for the reply, which fails the call after the prompt has already been paid for.
Questions to practice
Questions last reviewed 19 October 2026.
Roles this comes up in
Companies these come from
Other topics
- Filtering7
- Logical operators4
- Calculations11
- Conditional logic12
- NULL handling9
- Dates16
- Joins15
- Aggregations14
- Subqueries5
- Window functions32
- Reshaping15
- Arrays6
- Strings11
- Hashing8
- Two pointers4
- Sliding window1
- Binary search4
- Sorting1
- Math3
- Lists5
- Tuples3
- Dictionaries3
- Ranking16
- Running totals10
- Deduplication2
- Chunking1
- Similarity1
- Token budget2
- Parsing4
- Backoff3
- Agent loop1