# Where to Find Code Examples for Prompt Engineering Techniques in the Dair-AI Guide

> Discover prompt engineering code examples in the dair-ai/Prompt-Engineering-Guide repository. Find technique-specific MDX pages, Jupyter notebooks, and Markdown files to enhance your LLM interactions.

- Repository: [DAIR.AI/Prompt-Engineering-Guide](https://github.com/dair-ai/Prompt-Engineering-Guide)
- Tags: how-to-guide
- Published: 2026-03-03

---

**The dair-ai/Prompt-Engineering-Guide repository stores all prompt engineering code examples as Markdown files in [`guides/prompts-advanced-usage.md`](https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/guides/prompts-advanced-usage.md), technique-specific MDX pages in `pages/techniques/`, and executable Jupyter notebooks in `notebooks/` that you can copy-paste into any LLM playground or run programmatically.**

The dair-ai/Prompt-Engineering-Guide is the definitive open-source resource for learning prompt engineering. Whether you need copy-paste prompt templates for zero-shot classification or fully executable Python implementations using LangChain, the repository organizes every technique into readable Markdown guides and runnable Jupyter notebooks.

## Core Technique Examples in [`guides/prompts-advanced-usage.md`](https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/guides/prompts-advanced-usage.md)

The file [`guides/prompts-advanced-usage.md`](https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/guides/prompts-advanced-usage.md) serves as the master collection of prompt engineering techniques. It contains comprehensive, copy-paste-ready examples for every major method, including zero-shot, few-shot, chain-of-thought, and self-consistency prompting.

### Zero-Shot Prompting

Zero-shot examples require no prior examples in the prompt. The guide provides this classification template:

```text
Classify the text into neutral, negative, or positive. 

Text: I think the vacation is okay.
Sentiment:

```

*Expected output:*

```text
Neutral

```

### Few-Shot Prompting

For few-shot learning, the guide includes the classic "whatpu" example from Brown et al. (2020):

```text
A "whatpu" is a small, furry animal native to Tanzania. An example of a sentence that uses
the word whatpu is:
We were traveling in Africa and we saw these very cute whatpus.
To do a "farduddle" means to jump up and down really fast. An example of a sentence that uses
the word farduddle is:

```

*Expected output:*

```text
When we won the game, we all started to farduddle in celebration.

```

### Chain-of-Thought Prompting

The chain-of-thought (CoT) section demonstrates how to elicit step-by-step reasoning:

```text
The odd numbers in this group add up to an even number: 15, 32, 5, 13, 82, 7, 1. 
A:

```

*Expected output:*

```text
Adding all the odd numbers (15, 5, 13, 7, 1) gives 41. The answer is False.

```

### Zero-Shot CoT

For zero-shot chain-of-thought, the guide shows how adding "Let's think step by step" unlocks reasoning without examples:

```text
I went to the market and bought 10 apples. I gave 2 apples to the neighbor and 2 to the repairman.
I then went and bought 5 more apples and ate 1. How many apples did I remain with?

Let's think step by step.

```

*Expected output:*

```text
First, you started with 10 apples.
You gave away 2 apples to the neighbor and 2 to the repairman, so you had 6 apples left.
Then you bought 5 more apples, so now you had 11 apples.
Finally, you ate 1 apple, so you would remain with 10 apples.

```

### Self-Consistency

The self-consistency section provides prompts designed to be run multiple times to aggregate results:

```text
Q: There are 15 trees in the grove. Grove workers will plant trees in the grove today. After they are done,
there will be 21 trees. How many trees did the grove workers plant today?
A: We start with 15 trees. Later we have 21 trees. The difference must be the number of trees they planted.
So, they must have planted 21 - 15 = 6 trees. The answer is 6.

```

Running this prompt multiple times and selecting the majority answer improves robustness over single-sample chain-of-thought.

## Technique-Specific Reference Pages in `pages/techniques/`

For isolated deep-dives into single methods, the repository maintains dedicated MDX pages in the `pages/techniques/` directory. Each page follows a consistent format: explanation followed by runnable examples.

Key files include:
- `pages/techniques/zeroshot.en.mdx` – Dedicated zero-shot prompting reference
- `pages/techniques/reflexion.en.mdx` – Self-critique and reflexion techniques
- `pages/techniques/tot.en.mdx` – Tree-of-Thought recursive reasoning
- `pages/techniques.en.mdx` – Master index linking to all technique pages

These pages contain the same fenced code blocks found in the main guide, formatted for the project's documentation website.

## Executable Jupyter Notebooks in `notebooks/`

For programmatic implementation, the `notebooks/` directory contains executable Python examples that run prompts via APIs:

- `notebooks/pe-function-calling.ipynb` – Demonstrates function-calling prompts with LangChain or OpenAI function definitions
- `notebooks/pe-chatgpt-intro.ipynb` – Runs zero-shot, few-shot, and CoT prompts via the OpenAI API
- `notebooks/pe-lecture.ipynb` – Comprehensive lecture notebook covering multiple techniques

These notebooks allow you to execute the same prompts found in the Markdown guides programmatically, making them ideal for testing variations or integrating into Python applications.

## Summary

- **Primary location**: All copy-paste prompt examples live in [`guides/prompts-advanced-usage.md`](https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/guides/prompts-advanced-usage.md), covering zero-shot, few-shot, chain-of-thought, and advanced methods.
- **Deep-dive pages**: Isolated technique explanations and examples are stored in `pages/techniques/` as MDX files (e.g., `zeroshot.en.mdx`, `tot.en.mdx`).
- **Executable code**: Python implementations and API integrations are provided as Jupyter notebooks in `notebooks/` (e.g., `pe-chatgpt-intro.ipynb`, `pe-function-calling.ipynb`).
- **Usage**: All examples are plain-text fenced code blocks that you can copy directly into ChatGPT, Claude, Gemini, or any LLM playground.

## Frequently Asked Questions

### Where are the executable Python examples for prompt engineering?

The executable Python examples are located in the `notebooks/` directory. Files like `pe-chatgpt-intro.ipynb`, `pe-function-calling.ipynb`, and `pe-lecture.ipynb` contain runnable code that uses the OpenAI API and LangChain to execute the prompts programmatically, allowing you to test variations and integrate them into applications.

### What is the difference between the Markdown guides and the Jupyter notebooks?

The Markdown files in `guides/` and `pages/techniques/` provide static, copy-paste prompt templates designed for direct use in LLM chat interfaces. The Jupyter notebooks in `notebooks/` provide the same prompts wrapped in Python code, enabling programmatic execution, API parameter tuning, and automated testing via Python environments.

### How do I run the few-shot prompting examples from the guide?

To run few-shot examples, open [`guides/prompts-advanced-usage.md`](https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/guides/prompts-advanced-usage.md) and locate the "Few-Shot Prompting" section. Copy the fenced code block containing the "whatpu" and "farduddle" examples and paste it directly into ChatGPT, Claude, or any LLM playground. For programmatic execution, use `notebooks/pe-chatgpt-intro.ipynb` which runs these same prompts via the OpenAI API.

### Which file contains the chain-of-thought examples?

Chain-of-thought examples are located in [`guides/prompts-advanced-usage.md`](https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/guides/prompts-advanced-usage.md) under the "Chain-of-Thought Prompting" and "Zero-Shot CoT" sections. The file contains the classic odd-number arithmetic problem and the "Let's think step by step" apple-counting example. For an isolated reference page, see `pages/techniques/zeroshot.en.mdx` which also covers zero-shot CoT variants.