Skip to content

Zero Shot, Few Shot and Chain of Thought Prompting Explained with Examples

Learn when to use zero shot, few shot and chain of thought prompting, how self consistency improves accuracy, and when step by step reasoning hurts results on modern reasoning models.

Ucanly Team9 min read
Share

Most students who say "AI gave me a useless answer" asked a decent question in a weak way. The fix is rarely a magic phrase. It is knowing which of three basic prompting styles fits your task: zero shot, few shot, or chain of thought. Once you understand these, you can get better answers for placement prep, college projects, and daily learning, and you will also know when asking for long reasoning actually makes things worse.

This guide explains each technique with copyable examples, adds a fourth idea called self consistency, and ends with clear rules for modern reasoning models.

Zero shot prompting: just ask, but ask well

Zero shot means you give the model a task with no examples. You rely on what it already knows. This is how most people use ChatGPT, Claude, or Gemini, and for many tasks it is enough.

The difference between a weak and a strong zero shot prompt is not length. It is clarity about the task, the audience, the constraints, and the output format.

Weak: Explain normalization.

Better: Explain database normalization (1NF, 2NF, 3NF) to a third year CSE student preparing for placement interviews. Use one small student and course table as the running example. Keep it under 300 words and end with two interview questions I should be able to answer.

The better prompt tells the model who you are, what depth you need, which example to use, and what shape the answer should take. No examples were given, so it is still zero shot.

When zero shot works best

  • Explaining standard concepts (OS scheduling, OOP pillars, TCP vs UDP)
  • Summarising a document you paste in
  • Translating or simplifying text
  • Generating a first draft you will edit anyway

A reusable zero shot template

Task: [what you want done]
Context: [who you are, what you already know]
Constraints: [length, level, things to avoid]
Output format: [bullets, table, code, numbered steps]

If zero shot output keeps missing the style or structure you want, that is your signal to move to few shot.

Few shot prompting: show, do not just tell

Few shot means you include a small number of examples (usually two to five) of the input and output you want, then give the new input. The model picks up the pattern, tone, and format from your examples far more reliably than from a description.

This is extremely useful when the "right answer" is about style or structure rather than facts.

Example: rewriting resume bullets

Weak (zero shot): Make my resume bullet points sound better.

Strong (few shot): Rewrite each resume bullet in the same style as the examples. Start with a strong verb, mention the tool, and state the outcome. Do not invent numbers; if no metric is given, describe the impact in words.

Input: Made a website for college fest. Output: Built a responsive event website for the annual college fest using React, handling registrations for all participating departments.

Input: Did internship in data team. Output: Cleaned and analysed sales data in Python and Pandas during a summer internship, preparing weekly reports used by the team lead.

Input: Worked on a chatbot project. Output:

Notice the instruction "do not invent numbers". Without it, models love to add fake percentages, which can hurt you badly in an interview when someone asks you to explain them. After rewriting, run the final version through an AI resume review to check clarity and gaps.

Tips for good few shot examples

  • Keep examples consistent. If one output is two lines and another is ten, the model gets confused.
  • Cover variety. Include examples that differ in topic so the model learns the pattern, not the content.
  • Put the hardest case in. If some inputs are tricky (very vague bullets, for instance), show how you want those handled.
  • Label clearly. Use "Input:" and "Output:" or similar markers so the boundary is obvious.

Few shot for classification

Few shot also works well for sorting things into categories.

Classify each job posting as "Fresher friendly", "Needs experience", or "Unclear". Examples: "0 to 1 years, final year students may apply" → Fresher friendly "Minimum 3 years in production Java systems" → Needs experience "Looking for passionate developers" → Unclear

Now classify: "Graduates of 2025 and 2026 batches, strong DSA required"

This is handy when you are scanning listings on a jobs board and want a quick first pass before reading each one properly.

Chain of thought prompting: ask for the working

Chain of thought (often shortened to CoT) means asking the model to reason through intermediate steps before giving the final answer. It was popularised because older, non reasoning models made fewer mistakes on maths, logic, and multi step problems when they "showed their working", much like you do in an exam.

Basic version

A train leaves Bengaluru at 6:00 and travels at 60 km per hour. Another leaves the same station at 7:00 on the same track at 80 km per hour. When does the second train catch up? Think through it step by step, then give the final answer on a separate line.

Structured version

You can make the reasoning more useful by telling the model which steps to follow.

Solve this aptitude problem. First, list the given values. Second, write the formula you will use. Third, substitute and calculate. Fourth, check the answer by plugging it back in. Finally, state the answer.

This is excellent for learning, because you can compare each step against your own attempt and spot exactly where you went wrong.

Few shot chain of thought

You can combine techniques: give one or two fully worked examples with reasoning, then the new problem. This is powerful for aptitude rounds where questions follow familiar patterns like time and work, profit and loss, or permutations.

Q: [example question]
Reasoning: [step 1] [step 2] [step 3]
Answer: [final]

Q: [your new question]
Reasoning:

Self consistency: ask more than once

Self consistency is a simple idea. For a problem with one correct answer, you get the model to solve it several times independently, then trust the answer that appears most often. A single reasoning chain can go wrong at one step; several independent chains rarely all go wrong in the same way.

You can do this manually:

  1. Open a fresh chat (so earlier answers do not influence it).
  2. Ask the same question with a chain of thought request.
  3. Repeat two or three times.
  4. Compare final answers. If they agree, confidence goes up. If they disagree, look at where the reasoning diverges, that is usually the tricky part of the problem and exactly what you need to learn.

You can also ask within one chat:

Solve this problem using three different methods. Show each method separately, then tell me whether all three give the same answer. If they differ, explain which one is correct and why.

Self consistency is a good habit for anything numeric, any logic puzzle, and any output you plan to submit or rely on.

When NOT to ask for step by step reasoning

This is where many tutorials are now outdated. Modern reasoning models (the "thinking" modes in ChatGPT, Claude, Gemini and similar tools) already reason internally before answering. With these, adding "think step by step" often adds little, and very detailed instructions about how to think can sometimes constrain the model and make results worse.

Skip explicit chain of thought when

  • You are using a reasoning model. Give it a clear goal, the full context, and the constraints, then let it work. Ask for the final answer plus a short justification instead of a long walkthrough.
  • The task is simple recall. "What is the time complexity of binary search?" does not need a paragraph of reasoning.
  • You want short, formatted output. For a JSON object, a list of names, or a one line summary, reasoning text just gets in the way.
  • Speed and cost matter. Long reasoning means longer, slower responses.

Better prompt for a reasoning model

Over engineered: Think step by step. First consider every possible approach, then evaluate each one carefully, then think again about edge cases, then...

Better: I need the most efficient approach for finding the longest substring without repeating characters. Constraints: string length up to 100000. Give the approach, its time and space complexity, and the main edge cases. Keep the explanation brief.

A note on visible reasoning

Even when a model shows its reasoning, treat it as a helpful explanation, not proof. Models can produce reasoning that looks neat but contains an error, or arrive at the right answer with a weak explanation. Always verify important results yourself, especially calculations and code.

Choosing the right technique: a quick guide

  • Explaining a concept: zero shot with clear context.
  • Matching a specific style or format: few shot.
  • Maths, logic or aptitude on a standard model: chain of thought.
  • High stakes answer with one right result: chain of thought plus self consistency.
  • Any task on a reasoning model: clear goal and constraints, no "step by step".
  • Quick facts or short output: zero shot, and ask for brevity.

A practical workflow: start zero shot. If the format is wrong, add examples. If the logic is wrong, add reasoning (or switch to a reasoning model). If the answer matters, check it with self consistency.

What to do next

Prompting is a skill you build through practice, not by memorising phrases. This week, try this:

  • Take one concept from your syllabus and write a strong zero shot prompt for it using the template above.
  • Rewrite three of your resume bullets using the few shot pattern, without letting the model invent numbers.
  • Solve five aptitude questions yourself first, then compare with a chain of thought answer and note where you differed.
  • For one tricky problem, run self consistency across three fresh chats.

If you want a structured path for building AI and technical skills alongside placement prep, explore our courses and read more guides in this series on the blog.

Talk it through with a counsellor

Leave your number and someone from our team will call you with a plan for the career you are working towards.

Get a free career consultation

Tell us where you're headed and a counsellor will call you with a plan for getting there.

We use these details to respond to your request. The box above is only for marketing. See our privacy policy.

Try the free aptitude test

Fifteen questions in fifteen minutes, with every answer explained. Then a roadmap built from your score.