ASAmol Shukla
Projects
Learning Hub
Prompts
Skills
Contact
Resume
Course Outline
Syllabus Overview

Complete Prompt Engineering Course: From Basics to Mastery

Courses/Complete Prompt Engineering Course: From Basics to Mastery/Lesson 2: Core Prompting Techniques

Complete Prompt Engineering Course

Lesson 2: Core Prompting Techniques

Master zero-shot, few-shot, chain-of-thought, and other essential prompting strategies.

50 mins10 mins read

The Four Core Prompting Techniques

There are four fundamental techniques that form the foundation of prompt engineering. Master these and you'll handle 90% of prompting scenarios.

1. Zero-Shot Prompting

The simplest technique — give the model a task with no examples.

When to use: Simple, straightforward tasks where the model already has sufficient knowledge.

Example:

Classify this review as positive, negative, or neutral:
"The product arrived on time and works as expected."

Result: Positive

Pros: Fast, simple Cons: Less reliable for complex or nuanced tasks


2. Few-Shot Prompting

Provide examples of the desired input-output pattern before asking for new output.

When to use: Complex tasks, specific formatting requirements, or when you need consistent output.

Example:

Classify these reviews as positive, negative, or neutral:

Review: "Amazing quality, will buy again!" → Positive
Review: "Terrible, broke after one day." → Negative
Review: "It's okay, nothing special." → Neutral

Review: "The customer service was fantastic!" →

Result: Positive

Pros: More accurate, consistent output Cons: Uses more tokens, requires example selection


3. Chain-of-Thought (CoT) Prompting

Ask the model to show its reasoning step by step before giving the final answer.

When to use: Math, logic, complex analysis, or multi-step problems.

Example:

Solve this step by step:

A store sells shirts for $25 each. If you buy 3 or more, you get 20% off.
How much would 5 shirts cost?

Show your reasoning.

Step-by-step output:

  1. Price per shirt: $25
  2. Number of shirts: 5
  3. Since 5 ≥ 3, discount applies
  4. Discount: 20% of $25 = $5
  5. Discounted price per shirt: $25 - $5 = $20
  6. Total: 5 × $20 = $100

Pros: Improves accuracy for complex tasks, shows reasoning Cons: Longer outputs, more tokens


4. Self-Consistency

Run the same prompt multiple times and take the most common answer.

When to use: When accuracy is critical and you can afford multiple API calls.

How to implement:

  1. Generate 3-5 responses to the same prompt
  2. Compare the answers
  3. Use the most frequently occurring answer

Pros: Higher accuracy Cons: More expensive, slower


Advanced Techniques

Tree of Thought (ToT)

Explore multiple reasoning paths simultaneously and evaluate each.

When to use: Creative tasks, complex problem-solving, strategic planning.

Example:

I need to choose between 3 marketing strategies. Evaluate each:

Strategy A: Influencer marketing
Strategy B: Content marketing
Strategy C: Paid advertising

For each strategy, consider:
1. Cost
2. Time to results
3. Long-term value
4. Risk level

Then recommend the best option for a startup with limited budget.

Persona Prompting

Assign a specific role or expertise to the model.

When to use: When you need specialized knowledge or a specific perspective.

Example:

You are a senior financial advisor with 20 years of experience.
A 30-year-old client asks: "Should I invest in index funds or individual stocks?"

Provide advice in a conversational tone, explaining the reasoning
for your recommendation.

Prompt Chaining

Break complex tasks into a series of simpler prompts, where each output feeds into the next.

When to use: Multi-step tasks, research projects, content creation pipelines.

Example Chain:

  1. "List 10 trending topics in AI for 2026"
  2. "For each topic, write a one-paragraph summary"
  3. "Expand topic #3 into a 500-word blog post outline"

Choosing the Right Technique

Technique Best For Token Cost Accuracy
Zero-Shot Simple tasks Low Medium
Few-Shot Consistent formatting Medium High
Chain-of-Thought Reasoning tasks Medium-High High
Self-Consistency Critical accuracy High Very High
Tree of Thought Complex decisions High High
Persona Specialized knowledge Low-Medium High

Common Mistakes to Avoid

  • Mistake: Using few-shot when zero-shot works — Fix: Start simple, add examples only if needed.
  • Mistake: Not enough examples in few-shot — Fix: 3-5 examples usually work best.
  • Mistake: Forcing CoT on simple tasks — Fix: Use CoT only for multi-step reasoning.
  • Mistake: Copying examples that are too similar — Fix: Use diverse examples to show the pattern.

Professional Tips & Tricks

  • Start with zero-shot, upgrade to few-shot only if the output isn't good enough.
  • For chain-of-thought, explicitly ask for "step by step" — don't assume the model will do it.
  • Mix techniques: few-shot + CoT often produces the best results.
  • Test your prompts with edge cases, not just happy paths.

Key Takeaways

  • Zero-shot is fastest; few-shot is more reliable; CoT improves reasoning.
  • Choose the technique based on task complexity and accuracy needs.
  • Few-shot works best with 3-5 diverse examples.
  • Chain-of-thought significantly improves performance on reasoning tasks.
  • Combine techniques for optimal results.

Next up: Advanced prompting patterns — structured outputs, chain-of-thought variants, and prompt templates.

text · worked example
# Prompting Techniques Comparison

## 1. Zero-Shot
Simple task, no examples:
"Summarize this article in 3 sentences."

## 2. Few-Shot
With examples:
"Summarize these articles in 3 sentences:

Article: 'Apple reported record Q4 earnings...'
Summary: Apple achieved record Q4 earnings driven by strong iPhone sales.

Article: 'Tesla recalled 50,000 vehicles...'
Summary: Tesla issued a recall for 50,000 vehicles due to a software glitch.

Article: 'Microsoft announced new AI features...'
Summary: [Your response here]"

## 3. Chain-of-Thought
Step-by-step reasoning:
"Solve this step by step:
If a shirt costs $25 and there's a 20% discount on 3+ items,
how much do 5 shirts cost?

Let me think through this..."

## 4. Few-Shot + CoT (Combined)
Best of both worlds:
"Classify these customer sentiments. Show your reasoning.

Review: 'Love this product!' → 
Sentiment: Positive
Reasoning: Enthusiastic language, positive adjective

Review: 'Broke after one use.' →
Sentiment: Negative
Reasoning: Product failure, negative experience

Review: 'It works fine, nothing special.' →"

## Technique Selection Guide

| Task Type | Recommended Technique |
|-----------|----------------------|
| Simple classification | Zero-shot |
| Specific output format | Few-shot |
| Math/logic problems | Chain-of-thought |
| Critical decisions | Self-consistency |
| Creative brainstorming | Tree of thought |
| Domain expertise | Persona prompting |
| Multi-step projects | Prompt chaining |
Read-only sample

Lesson Code (text)

# Prompting Techniques Comparison

## 1. Zero-Shot
Simple task, no examples:
"Summarize this article in 3 sentences."

## 2. Few-Shot
With examples:
"Summarize these articles in 3 sentences:

Article: 'Apple reported record Q4 earnings...'
Summary: Apple achieved record Q4 earnings driven by strong iPhone sales.

Article: 'Tesla recalled 50,000 vehicles...'
Summary: Tesla issued a recall for 50,000 vehicles due to a software glitch.

Article: 'Microsoft announced new AI features...'
Summary: [Your response here]"

## 3. Chain-of-Thought
Step-by-step reasoning:
"Solve this step by step:
If a shirt costs $25 and there's a 20% discount on 3+ items,
how much do 5 shirts cost?

Let me think through this..."

## 4. Few-Shot + CoT (Combined)
Best of both worlds:
"Classify these customer sentiments. Show your reasoning.

Review: 'Love this product!' → 
Sentiment: Positive
Reasoning: Enthusiastic language, positive adjective

Review: 'Broke after one use.' →
Sentiment: Negative
Reasoning: Product failure, negative experience

Review: 'It works fine, nothing special.' →"

## Technique Selection Guide

| Task Type | Recommended Technique |
|-----------|----------------------|
| Simple classification | Zero-shot |
| Specific output format | Few-shot |
| Math/logic problems | Chain-of-thought |
| Critical decisions | Self-consistency |
| Creative brainstorming | Tree of thought |
| Domain expertise | Persona prompting |
| Multi-step projects | Prompt chaining |

Console Output

Prompting Techniques Comparison

## 1. Zero-Shot
Simple task, no examples:
"Summarize this article in 3 sentences."

## 2. Few-Shot
With examples:
"Summarize these articles in 3 sentences:

Article: 'Apple reported record Q4 earnings...'
Summary: Apple achieved record Q4 earnings driven by strong iPhone sales.

Article: 'Tesla recalled 50,000 vehicles...'
Summary: Tesla issued a recall for 50,000 vehicles due to a software glitch.

Article: 'Microsoft announced new AI features...'
Summary: [Your response here]"

## 3. Chain-of-Thought
Step-by-step reasoning:
"Solve this step by step:
If a shirt costs $25 and there's a 20% discount on 3+ items,
how much do 5 shirts cost?

Let me think through this..."

## 4. Few-Shot + CoT (Combined)
Best of both worlds:
"Classify these customer sentiments. Show your reasoning.

Review: 'Love this product!' → 
Sentiment: Positive
Reasoning: Enthusiastic language, positive adjective

Review: 'Broke after one use.' →
Sentiment: Negative
Reasoning: Product failure, negative experience

Review: 'It works fine, nothing special.' →"

## Technique Selection Guide

| Task Type | Recommended Technique |
|-----------|----------------------|
| Simple classification | Zero-shot |
| Specific output format | Few-shot |
| Math/logic problems | Chain-of-thought |
| Critical decisions | Self-consistency |
| Creative brainstorming | Tree of thought |
| Domain expertise | Persona prompting |
| Multi-step projects | Prompt chaining |

Code Visualization Tips

  • Create a decision tree for choosing the right prompting technique.
  • Draw a flowchart showing how few-shot examples guide the model's output.
  • Use a comparison table to visualize the trade-offs between techniques.

Professional Tips & Tricks

  • Always test with at least 3 examples in few-shot to establish a clear pattern.
  • For chain-of-thought, adding 'Let me think step by step' as a prefix improves results.
  • Use delimiters (---, ###, |||) to separate examples from the actual task.

Python Code Judge & Practice Arena

LeetCode Style

Run real Python 3.12 WebAssembly code directly in your browser against automated test suites.

Solved:0 / 2
0 / 40 XP
Challenges:
Problem 1 of 2

Few-Shot Creation

Medium+20 XP
Create a few-shot prompt that converts informal text to formal business language. Include at least 3 examples.
main.pyPython 3.12 (WASM)
1
2
3
4
5
6
7
8
9
10
11
12
Press Run Code to test or Submit to verify test cases

Test Your Knowledge

Instant feedback

Quick Check: Core Prompting Techniques

1 / 3
What is zero-shot prompting?

Up next · Continue learning

Structured Outputs & Prompt Templates

Master techniques for getting consistent, structured outputs and building reusable prompt templates.

9 mins read45 mins
Start next lesson
Previous: Introduction to Prompt EngineeringNext: Structured Outputs & Prompt Templates
Made withbyAmol Shukla·amolshukla.online
ASAmol Shukla

AI Developer, Trainer & Agentic AI Expert building practical learning systems and real-world AI applications.

Explore

  • Projects
  • Learning Hub
  • Prompts
  • Skills
  • Contact
  • Experience
  • Blogs

Connect

  • Resume
  • Contact
© 2026 Amol Shukla·Created withbyamolshukla.online
Back to top