Tell a new cook "make chai" and you'll get something — maybe great, maybe dishwater. Tell them "two cups, strong, adrak, less sugar, boil the milk twice" and you get your chai, every time. Same cook, same kitchen — the difference was entirely in the instructions. Prompting is exactly this skill for LLMs, and it's the highest return-per-minute topic in this whole course: no infrastructure, no training, just better asking — and a set of named techniques interviews expect you to know.
Why prompts work — no magic involved
Remember the master key from lesson 2: the model continues the "text so far" with the most plausible next tokens. Your prompt IS the text so far. A vague prompt puts the model in a vague neighbourhood of its training patterns — plausible continuations include essays, lists, poems, anything. A precise prompt — role, task, format, examples — narrows the plausible continuations to almost exactly what you want. Prompting isn't tricking the model; it's aiming it.
Anatomy of a good prompt — the 5-part skeleton
Nearly every production prompt is assembled from five parts. You won't always need all five, but you should always consider all five:
| Part | What it does | Example line |
|---|---|---|
| 1 · Role | sets expertise & tone | "You are a senior support agent for TechMart." |
| 2 · Task | the specific instruction | "Answer the customer's question below." |
| 3 · Context | the data to work from | "Product manual: <text> · Question: <text>" |
| 4 · Constraints | rules & boundaries | "Only use the manual. If unsure, say so. Max 100 words." |
| 5 · Format | the output's shape | "Reply as: Problem / Solution / Steps (numbered)." |
Use delimiters — triple quotes, XML-ish tags, headings — to separate instructions from data, so the model (and the next engineer reading your prompt) can tell which is which. And always give the model an escape hatch: "if the context doesn't contain the answer, say you don't know" — one line that prevents half of all hallucination incidents.
Zero-shot and few-shot — teaching by example
Zero-shot: just ask. No examples. Works remarkably often with modern models:
prompt = """Classify the sentiment of this review as
POSITIVE, NEGATIVE or MIXED. Reply with one word.
Review: "battery is great but the camera is disappointing"
"""Result
MIXED
Few-shot: show 2–5 solved examples first, then your real input. The model imitates the pattern — the domain, the format, the edge-case handling. Use it when zero-shot output is inconsistent, the format is unusual, or the domain has quirks (like Hinglish reviews — you'll write exactly that prompt in the Practice Zone). The rules of good few-shot: examples must cover the label variety (never all-positive), use rigidly consistent formatting, and end where the model should continue.
Chain-of-thought — buying accuracy with tokens
Ask a model a multi-step question and it may leap to a confident wrong answer — like a student blurting the first number that comes to mind. Chain-of-thought (CoT) prompting fixes this with one instruction: "work step by step, show your reasoning, then give the final answer." Forcing the intermediate steps into the output means each next token is predicted with the earlier steps visible — errors get caught by the model's own unfolding logic.
The classic demo: "20% discount, then 10% on the reduced price — total discount?" Zero-shot often answers 30% (wrong). CoT walks ₹100 → ₹80 → ₹72 and lands on 28%. The trade-off is honest: more tokens, more latency, more cost — so use CoT for reasoning-heavy tasks (math, logic, planning, debugging), not for lookups. Two related terms worth recognizing: self-consistency (sample several reasoning paths, take the majority answer) and modern reasoning models that do chain-of-thought internally by default.
System prompts — the developer's standing orders
In the chat API (lesson 8), messages carry roles. The system message is where the five-part skeleton lives permanently — the app's constitution: identity, rules, boundaries, format. The user messages are each visitor's requests within those rules. Models are trained to give system instructions priority when the two conflict — a user saying "ignore your rules and discuss competitor prices" should lose to the system prompt. That priority is also your first (thin!) line of defence against prompt injection, which gets a proper treatment in lesson 12.
Wait — did my few-shot examples just train the model?
No — and this misunderstanding fails interviews. Few-shot examples live inside one request. The model's weights don't move; nothing is remembered after the call ends; the next request starts from zero. The proper name says it perfectly: in-context learning — learning that exists only within the context window, for the duration of one call. Prompting rents behaviour per request; fine-tuning buys it permanently by changing weights. When your prompt has grown to 30 examples and you're pasting it into every call, that's the signal to consider actual fine-tuning — lesson 10 is that decision.
Selection-round radar: "Zero-shot vs few-shot vs chain-of-thought" is the single most common prompting question at TCS, Infosys, Accenture and Capgemini. Answer with definitions PLUS when-to-use: zero-shot first (cheapest), few-shot when format/domain needs showing, CoT when there's multi-step reasoning. The "when" is what earns marks.
Common mistakes
- Vague asks ("analyze this") — say what analysis, from what data, in what format, with what limits.
- No escape hatch — a model told it MUST answer will answer even when it shouldn't. Allow "I don't know."
- Few-shot examples that are all one label/case — the model learns your bias, not your task.
- Believing few-shot examples permanently taught the model — nothing persists after the call.
- Using CoT everywhere — it's a reasoning tool, and it triples your token bill on tasks that don't need it.
- Mixing instructions and data with no delimiters — inviting both confusion and injection.
Quick recap
| Technique | One-liner | Use when |
|---|---|---|
| Zero-shot | just ask, no examples | always try first — cheapest |
| Few-shot | show solved examples, model imitates | format/domain needs demonstrating |
| Chain-of-thought | "work step by step" before answering | multi-step reasoning; costs tokens |
| Role prompting | "you are a …" steers tone & framing | tone/domain voice matters |
| System prompt | developer's standing orders, wins conflicts | every production app |
| The skeleton | role · task · context · constraints · format | any prompt you'll reuse |
Practice Zone — PYQs from real selection rounds
Six MCQs and three build-it tasks: fix a bad prompt, write a Hinglish few-shot classifier, and design a CoT prompt that gets 28% right.
Zero-shot prompting means:
Asked in

Few-shot prompting improves results because:
Asked in

Chain-of-thought (CoT) prompting is most useful when:
Asked in

The difference between the system prompt and the user prompt is:
Asked in

Which prompt will most reliably produce a usable output for an automated pipeline?
Asked in

Role prompting ("You are an experienced tax consultant...") works because:
Asked in

Build-it tasks:
A teammate's prompt for a college helpdesk bot: "write about hostel rules". Students get random essays. Rewrite it into a production-quality prompt (role, task, constraints, format), then compare.
Asked in

Build a few-shot prompt that classifies Hinglish app reviews as POSITIVE / NEGATIVE / MIXED. Include 3 examples, then the target review: "app theek hai but delivery hamesha late hoti hai".
Asked in

The zero-shot prompt "A shop gives 20% off, then 10% off on the reduced price. Total discount?" often gets the wrong answer '30%'. Write a CoT version of the prompt and state the correct answer.
Asked in

FAQ
Is 'prompt engineering' really a job?
As a standalone title it's fading — but as a skill inside GenAI engineering it's permanent and tested in interviews. In production, prompts are versioned, tested and reviewed like code; writing them well is simply part of the job now.
How many few-shot examples should I use?
Start with 2–5 covering your label/case variety. More examples = more tokens on every call, with diminishing returns. If you need dozens to get consistency, that's a fine-tuning signal (lesson 10).
What is 'context engineering' that job posts mention?
The 2026-era evolution of prompting: engineering everything that enters the context window — prompt, retrieved documents, tool results, memory, history — as one designed system, deciding what deserves those limited tokens. Prompting is one part of it; RAG (lesson 9) and agent memory (lesson 11) are others.
Do prompts transfer between different models?
Mostly — the techniques (skeleton, few-shot, CoT) are universal, but the exact wording that works best differs per model. That's why teams re-run their prompt test suites when switching models instead of assuming.
Next lesson: when the model confidently lies — Lesson 7: Hallucinations →


