Beginner-Friendly Topic
Take your time - it's perfectly normal to re-read this topic 2-3 times. Try the interactive code editor below to run code yourself. Use the Q&A section to check your understanding before moving on. You've got this! 🚀
Give Examples
Giving examples in your prompt is one of the most powerful techniques in prompt engineering. When AI sees an example, it understands your expected style, format, and quality level immediately.
Why Examples Work
An example shows AI exactly what you mean instead of trying to describe it in words.
This is called few-shot prompting (covered in depth in Module 4).
When you include an example:
- AI matches the tone of the example
- AI follows the format of the example
- AI understands the level of detail you expect
- AI uses a similar structure in its response
This is often more effective than trying to describe the style in words.
Deep Learning ⊂ Machine Learning ⊂ Artificial Intelligence
Examples in Prompts
# Using examples to guide AI output
# Without an example:
no_example = """
Write a product tagline for a note-taking app.
"""
# AI might write anything. You have no control over the style.
# With an example:
with_example = """
Write a product tagline for a note-taking app.
Use this style: short, punchy, focused on the benefit.
Example of the style I want:
'Capture everything. Miss nothing.'
Now write a tagline for our app.
"""
# AI understands the exact style you want and follows it.
# Another example: email tone
email_example = """
Rewrite this customer support email in a warmer, friendlier tone.
Here is an example of the tone I want:
'Hi Sarah! Thanks so much for reaching out.
We completely understand how frustrating this must be...'
Here is the email to rewrite:
[paste email here]
"""
print("Examples communicate style faster than descriptions.")Key Takeaways
- Examples show AI exactly what you want instead of describing it in words
- Examples guide tone, format, length, and style simultaneously
- One good example is often enough to set the direction
- This technique is called few-shot prompting
- Using examples is one of the fastest ways to improve AI output quality
Key Takeaways
- Giving examples in your prompt is one of the most powerful techniques in prompt engineering.
- Examples show AI exactly what you want instead of describing it in words
- Examples guide tone, format, length, and style simultaneously
- One good example is often enough to set the direction