Module 2.2: Zero-Shot, Few-Shot, and Chain-of-Thought Prompting

YOUR PROGRESS — GENERATIVE AI: ZERO TO JOB-READY ← Course home
5 of 20 modules complete
GENERATIVE AI: ZERO TO JOB-READY  ›  UNIT 2  ›  MODULE 2 OF 4

Zero-Shot, Few-Shot, and Chain-of-Thought Prompting

⏱ 15 min read 📝 Assignment inside Requires Module 2.1

In Module 2.1 you learned the six components of a well-structured prompt. This module teaches three specific techniques that sit on top of that foundation — the highest-impact methods professional prompt engineers use every day.

These are not advanced or theoretical. They are practical patterns you can start using in your next AI session. By the end of this module you will know exactly when to use each technique and how to combine them.


The three techniques — quick overview

Three prompting techniques overview: Zero-shot asks directly with no examples, Few-shot provides examples before the task, Chain-of-thought asks the model to reason step by stepZero-ShotAsk directly. No examples.Works for clear, simple tasks.Start here always.Few-ShotGive 1–3 examples first,then state the task.Use when format or style matters.Chain-of-ThoughtAsk the model to reasonstep by step.Use for complex problems.

Technique 1 — Zero-Shot Prompting

Zero-shot means asking the model to do something directly, without providing any examples. You describe the task and let the model use its training to handle it.

Zero-Shot Prompting
Start here for every task

The model relies entirely on patterns from its training data. No examples needed. Modern models like GPT-4o, Claude Sonnet, and Gemini Pro handle zero-shot well for most everyday tasks — especially when your six-component prompt structure from Module 2.1 is in place.

ZERO-SHOT EXAMPLE 1 — Code explanation
You are a senior Python developer explaining code to a junior colleague.

Explain what this function does, line by line, in plain English. No jargon.

def find_duplicates(lst): seen = set() duplicates = [] for item in lst: if item in seen: duplicates.append(item) else: seen.add(item) return duplicates

WHY THIS WORKS
Role + task + constraint (“no jargon”) + the code itself as context. The model has everything it needs. No example of the output style was needed because “line by line, plain English” is clear enough.

ZERO-SHOT EXAMPLE 2 — Email draft
You are a professional communicator writing on behalf of a software engineer.

Draft an email to my project manager at Wipro explaining that the API integration task will be delayed by 2 days because the third-party vendor has not shared the documentation.

Tone: professional but direct. Under 120 words. No apology in the subject line.

WHY THIS WORKS
Context (Wipro, API integration, vendor delay), task (draft email), format (under 120 words), constraint (no apology in subject). Zero-shot is completely sufficient here — the model knows what a professional email looks like.

When zero-shot is enough: Most everyday tasks — summaries, drafts, explanations, translations, code review, simple analysis. If the model knows what "good output" looks like from its training (which it does for most common tasks), zero-shot with a well-structured prompt is all you need.

Technique 2 — Few-Shot Prompting

Few-shot means providing 1–3 examples of the input-output pattern you want before stating your actual task. The model learns the pattern from your examples and applies it.

Why few-shot works: Examples show the model the format, tone, and level of detail you want — far more precisely than describing it in words. A single well-chosen example is often worth more than three paragraphs of formatting instructions.
Few-Shot Prompting
Use when style or format matters

You provide example input-output pairs first, then give the model the real input. The model matches your demonstrated pattern. This is one of the highest-ROI prompt techniques available — even one example dramatically improves output consistency for style-sensitive tasks.

FEW-SHOT EXAMPLE 1 — LinkedIn post style matching
I write LinkedIn posts in a specific style. Here are two examples:

Example 1: “3 things I learned failing my first Infosys interview:

  1. They care more about how you think than what you know
  2. Saying ‘I don’t know, but here’s how I’d find out’ beats guessing
  3. Your CGPA is the entry ticket — personality is the interview What would you add?”

Example 2: “Just got my first internship offer. Not from campus placement. From a cold email I sent 6 weeks ago. Template I used: [link] Your network is not who you know. It’s who knows you’re looking.”

Now write a LinkedIn post in the same style about completing a free online AI course and how it helped me stand out in a TCS interview.

WHY THIS WORKS
Without examples, the model would produce a generic “I’m excited to share…” LinkedIn post. With two examples, it learns your exact style — punchy numbered lists, conversational tone, India-specific references, ending with a hook. The output will sound like you, not like AI.

FEW-SHOT EXAMPLE 2 — Consistent bug report format
Convert the following developer notes into a formal bug report. Use this format:

Example input: “login page crashes when you type a really long email” Example output: Title: Login page crashes on email input exceeding character limit Severity: High Steps to reproduce:

  1. Navigate to login page
  2. Enter email address longer than 255 characters
  3. Click Submit Expected behaviour: Input validation error displayed Actual behaviour: Application crashes with 500 error Environment: Chrome 124, Windows 11

Now convert this note: “the export to CSV button doesn’t work when there are more than 500 rows in the table”

WHY THIS WORKS
The example defines both the exact format and the level of technical precision needed. Zero-shot with just “write a bug report” would give you a generic format. One example gives you your exact team format every time.

FEW-SHOT EXAMPLE 3 — Interview Q&A generation
Generate interview questions and model answers for a TCS technical round. Follow this format exactly:

Q: What is polymorphism in OOP? A: Polymorphism means one interface, many implementations. In Java, this happens through method overloading (same method name, different parameters) and method overriding (subclass redefines parent’s method). Example: a Shape class with an area() method — Circle, Rectangle, and Triangle each implement area() differently, but you can call shape.area() on any of them. Why it matters in interviews: Shows you understand OOP principles with a concrete example, not just a textbook definition.

Generate 3 more Q&As in the same format for: Exception handling, Collections framework, and Multithreading.

WHY THIS WORKS
The single example defines three things at once — the Q&A format, the depth of explanation expected, and the “why it matters” framing. The model replicates all three for every subsequent question. This technique saves hours when building interview prep materials.


Technique 3 — Chain-of-Thought (CoT) Prompting

Chain-of-thought prompting asks the model to show its reasoning step by step before giving a final answer. This dramatically improves accuracy on problems that require reasoning, analysis, or multi-step logic.

Chain-of-Thought Prompting
Use for complex reasoning tasks

Instead of asking for a direct answer, you ask the model to reason through the problem first. The act of generating the reasoning process improves the final answer — the model is less likely to jump to a wrong conclusion when it has to show its work.

COT EXAMPLE 1 — Simple trigger phrase
A project has 3 developers. Developer A can complete the backend in 6 days alone. Developer B can complete it in 4 days alone. Developer C can complete it in 12 days alone. If all three work together, how many days will it take to complete the backend?

Think through this step by step before giving your answer.

THE CoT TRIGGER
“Think through this step by step” is the simplest CoT trigger. Without it, the model often jumps to a number directly — and gets it wrong. With it, the model works out the rates (1/6 + 1/4 + 1/12 = 2/12 + 3/12 + 1/12 = 6/12 = 1/2 per day → 2 days), shows the working, and arrives at the correct answer.

COT EXAMPLE 2 — Technical decision analysis
I am building a REST API for an Indian ed-tech startup. Expected users: 50,000 per month. Budget is limited. I need to decide between hosting on AWS, Azure, or a basic VPS like DigitalOcean.

Analyse each option step by step:

  1. First evaluate cost at our scale
  2. Then evaluate ease of setup for a 2-person team
  3. Then evaluate scalability if we grow to 500,000 users
  4. Then give your recommendation with reasoning

Do not give the recommendation until you have completed all four steps.

WHY THE STRUCTURE MATTERS
The numbered steps force the model to evaluate each dimension before concluding. Without this, the model typically jumps to “use AWS” based on training patterns — missing the budget and team-size constraints entirely. The explicit “do not give the recommendation until…” instruction prevents premature conclusions.

COT EXAMPLE 3 — Career decision
I have two job offers: Offer A: TCS, Chennai, ₹4.2 LPA, Java development, 9–6 fixed hours Offer B: Startup, Bengaluru, ₹3.8 LPA, Full-stack, flexible hours, ESOPs

I am a fresher from Coimbatore. My goal is to move into AI/ML in 3–4 years.

Reason through this decision carefully:

  • First, consider which role builds more transferable skills for AI/ML
  • Then consider the financial and lifestyle factors
  • Then consider the risk profile of each option
  • Finally, give your recommendation and explain the single most important factor

Think step by step.

WHY THIS WORKS FOR INDIAN STUDENTS
Career decisions with Indian-specific context (LPA, city preferences, family expectations around stability vs startup risk) benefit enormously from CoT. The model considers multiple dimensions before concluding — giving you a genuinely reasoned answer, not just “follow your passion.”


Combining the three techniques

The real power comes from combining techniques. Here is a complete example that uses all three — zero-shot structure, few-shot for style, and CoT for the analysis:

COMBINED EXAMPLE — Technical interview preparation
You are an experienced technical interviewer at a top Indian IT company. [ROLE — zero-shot]

I have a system design interview at Infosys tomorrow for a backend developer role. [CONTEXT]

Here is an example of how I want you to break down a system design question:

Question: “Design a URL shortener like bit.ly” Answer structure: Step 1 — Clarify requirements (scale, features, constraints) Step 2 — High-level architecture (components and data flow) Step 3 — Database design (schema, choice of DB type) Step 4 — Key trade-offs (consistency vs availability, SQL vs NoSQL) Step 5 — What I would improve given more time [ONE EXAMPLE — few-shot]

Now use that same structure to break down this question step by step: “Design a notification system that sends 10 million push notifications per day.”

Think through each step carefully before moving to the next. [CoT trigger]

This single prompt will produce a structured, interview-ready answer that follows your preferred format, covers the right depth, and shows reasoning at each step. This is the level of prompting that separates good AI users from great ones.


When to use which technique

DECISION GUIDE — CHOOSING THE RIGHT TECHNIQUE
Simple, well-defined task (email, summary, code explanation)? Zero-shot. Add role + task + format. Done.
Output style or format matters (LinkedIn post, bug report, PR review)? Few-shot. Provide 1–2 examples first. The model matches your pattern exactly.
Multi-step reasoning, analysis, or decision-making? Chain-of-thought. Add "think step by step" or break it into numbered reasoning steps.
Complex task where format AND reasoning both matter? Combine all three. Use zero-shot structure, add one example, add a CoT trigger.
Not sure? Where to start? Always start with zero-shot. Upgrade to few-shot or CoT only if the output is not good enough. Adding complexity before it is needed wastes time.

Quick reference — technique comparison

Zero-Shot
  • No examples needed
  • Fastest to write
  • Works for most everyday tasks
  • Relies on model training
  • Start here always
Best for: Summaries, drafts, explanations
Few-Shot
  • 1–3 examples provided
  • Takes 2–5 min to set up
  • Consistent format output
  • Style matches your examples
  • Reuse examples across sessions
Best for: Posts, reports, structured docs
Chain-of-Thought
  • Add reasoning steps
  • One phrase triggers it
  • Higher accuracy on logic
  • Longer but more reliable
  • Good for decisions
Best for: Analysis, decisions, math

Tool-specific notes for 2026

ToolZero-ShotFew-ShotChain-of-Thought
ChatGPT (GPT-4o)Excellent — infers intent well even from brief promptsHandles 1–3 examples cleanly; put examples before the task"Think step by step" works reliably; also responds well to numbered reasoning steps
Claude (Sonnet)Strong — particularly good at following format constraints without examplesVery responsive to examples; use XML-style tags to separate examples from task for best resultsExcellent CoT — add "reason through this carefully" for nuanced analysis; tends to be thorough
Gemini (Pro)Good — place the task question at the end of the prompt, after any contextGoogle's own guidelines recommend always using few-shot for complex tasks; Gemini benefits more from examples than the other twoWorks well; add explicit numbered steps rather than relying on "think step by step" alone

The three things to remember

KEY TAKEAWAYS — MODULE 2.2
  1. Zero-shot first, always — most well-structured prompts work without examples. Only add examples (few-shot) or reasoning steps (CoT) when zero-shot output is not good enough. Adding complexity before it is needed slows you down.
  2. Few-shot is about style, not information — use it when you want the model to match a specific format, tone, or structure. One well-chosen example beats three paragraphs of format instructions every time.
  3. Chain-of-thought prevents wrong answers on hard problems — when the task involves multi-step reasoning, "think step by step" is not optional. Without it, models jump to plausible-sounding but wrong conclusions. With it, accuracy improves significantly.

Assignment 2.2 — Use All Three Techniques on Real Tasks

Three tasks, one technique each. Each should take 10–15 minutes including testing.

  1. Zero-shot task: Write a zero-shot prompt asking AI to explain a technical concept from your domain (OS, DBMS, networking, or any subject you are studying). Use the six-component structure from Module 2.1. Test it and note the output quality.
  2. Few-shot task: Write a LinkedIn post about a project or achievement using few-shot prompting. Provide two examples of LinkedIn posts you admire first, then ask the model to write yours in the same style. Compare the output to what you would have got without examples.
  3. Chain-of-thought task: Give the model a real decision you are facing — a course to take, a tool to learn, a job offer to evaluate, or a project architecture decision. Ask it to reason through the decision step by step across at least three dimensions before concluding. Note whether the recommendation surprises you.
  4. Add all three prompts to your AI Learning Journal with a note on which technique made the most difference for each task.

After this assignment you will have used all three techniques on your own real work. That hands-on calibration is more valuable than any amount of reading about the techniques.

Sources and references
ClaimSource
Few-shot remains one of highest-ROI prompt techniques; try zero-shot before few-shotThomas Wiegold, Prompt Engineering Best Practices 2026
Gemini benefits more from few-shot; Google recommends examples for complex tasksGoogle Gemini prompt engineering whitepaper, cited in Thomas Wiegold 2026
Claude responds well to contract-style instructions and XML tags for example separationLakera Prompt Engineering Guide 2026; Anthropic prompt engineering docs
CoT improves accuracy on multi-step reasoning; "think step by step" triggerWei et al. 2022 "Chain-of-Thought Prompting Elicits Reasoning"; k2view.com 2026
ChatGPT infers intent well even from brief prompts; crisp constraints work wellLakera Prompt Engineering Guide 2026