Mastering Prompting Techniques: From Zero-Shot to Persona-Based

Prompting is the art of asking AI the right way. In this blog, we’ll explore key prompting techniques—zero-shot, one-shot, chain of thought, self-consistency, and persona-based prompting—with simple explanations and examples.
𝌞 Table of Contents
Introduction: Why Prompting Matters
Zero-Shot Prompting
One-Shot Prompting
Chain of Thought (CoT) Prompting
Self-Consistency Prompting
Persona-Based Prompting
Introduction: Why Prompting Matters
Generative AI responds based on how we “ask” questions.
Good prompts = better answers.
This blog explains 5 key prompting techniques with examples.
Zero-Shot Prompting
Definition: Asking the AI without giving it any examples.
Analogy: Like giving a quiz question without studying beforehand.
Example: “Translate ‘Hello’ into French.”
Works well for simple, direct tasks.
One-Shot Prompting
Definition: Asking with one example.
Analogy: Teaching a kid by showing one solved problem before asking them to try.
Example:
- Input: “Translate ‘Hello’ into Spanish → Hola. Now translate ‘Good morning’ into French.”
Useful for guiding AI with a pattern.
from openai import OpenAI
client = OpenAI()
SYSTEM_PROMPT= '''
Hello chat you care a photographer, Here any one will ask you question about photography only, you need to answer only photgraphy related question
if any one ask question other then ai, you can direct answer not supported
'''
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role":"system","content": SYSTEM_PROMPT},
{"role":"user","content":"hey How are you"},
{"role":"assistant","content":"I'm here to help you with photography questions! What would you like to know?"},
{"role":"user","content":"explain video graphy to me"},
{"role":"assistant","content":"I'm focused on photography-related topics. If you have any questions specifically about photography, feel free to ask!"},
{"role":"user","content":"Please tell me differenct camera angle for sunset photo click "},
]
)
print(response.choices[0].message.content)
- Result:
When capturing sunset photos, different camera angles can dramatically affect the mood and composition of your image. Here are some camera angles you might consider:
1. **Low Angle**: Shooting from a low angle, close to the ground, can add foreground interest (like grass or flowers) and make the sunset appear larger and more dramatic.
2. **Eye Level**: This angle creates a natural perspective. Positioning the camera at eye level allows a straightforward view of the sunset and surrounding landscape.
3. **High Angle**: If you can elevate your camera position (for example, shooting from a hill or a building), a high angle can offer a unique perspective, capturing the vastness of the sky and the landscape below.
4. **Tilted Angle (Dutch Angle)**: A slightly tilted camera can create a more dynamic and artistic shot, especially if you're capturing the reflection of the sunset in water.
5. **Framing with Foreground Elements**: Use elements in the foreground (like trees, rocks, or silhouettes) to frame the sunset and give a sense of depth. This can be done at various angles.
6. **Wide Angle**: Using a wide-angle lens allows you to capture more of the scene, making your sunset photo grander and more immersive.
7. **Long Exposure Angle**: For a smoother effect on the sky, consider using long exposure techniques. This typically involves a tripod to keep the camera steady while you capture the transition of light.
Experimenting with these angles will help you find the best composition for your sunset photography!
Chain of Thought (CoT) Prompting
Definition: Asking AI to “think step by step.”
Analogy: Solving math problems by showing each step instead of just the final answer.
Example: “If there are 3 apples and you buy 2 more, step by step, how many do you have?”
Improves reasoning and problem-solving.
```python from openai import OpenAI import json
client = OpenAI()
Chain Of Thought: The model is encouraged to break down reasoning step by step before arriving at an answer.
SYSTEM_PROMPT = """ You are a helpful AI assistant that always explains your reasoning step by step before giving the final answer. This is called the Chain of Thought (CoT) technique.
Instructions:
- When the user asks a question, first break it down into small steps.
- Write out your thought process clearly (like solving a puzzle step by step).
- After reasoning, provide the final answer in a simple and clear way.
Always include both "reasoning" and "final_answer" in the JSON response.
Output Format: { "reasoning": "string", "final_answer": "string" }
Example 1: Input: What is 12 3 + 6? Output: { "reasoning": "First multiply 12 3 = 36. Then add 6. 36 + 6 = 42.", "final_answer": "42" }
Example 2: Input: Tom has 10 pencils. He gives 3 to Mary and then buys 5 more. How many pencils does he have? Output: { "reasoning": "Start with 10 pencils. Give away 3, so 10 - 3 = 7. Then add 5 new pencils: 7 + 5 = 12.", "final_answer": "12" } """
messages = [ { "role": "system", "content": SYSTEM_PROMPT } ]
query = input("> ") messages.append({ "role": "user", "content": query }) while True: response = client.chat.completions.create( model="gpt-4.1", response_format={"type": "json_object"}, messages=messages )
messages.append({ "role": "assistant", "content": response.choices[0].message.content }) parsed_response = json.loads(response.choices[0].message.content)
Handle Chain of Thought reasoning
if parsed_response.get("reasoning"): print(" 🧠 Reasoning:", parsed_response.get("reasoning"))
if parsed_response.get("final_answer"): print("🤖 Final Answer:", parsed_response.get("final_answer")) break ```
Self-Consistency Prompting
Definition: Asking AI multiple times and picking the most common/best answer.
Analogy: Asking many friends the same riddle and choosing the answer most of them agree on.
Example: Math word problems or logical puzzles.
Increases accuracy by reducing randomness.
Persona-Based Prompting
Definition: Telling AI to “act like” a specific person or role.
Analogy: Asking a teacher vs. asking a comedian → the same question gives very different answers.
Example: “You are a history teacher. Explain World War II in simple words.”
Great for tone, style, and role-based answers.
Here’s an example created by another student from our cohort: Aasu Yadav — Persona Bot.
I will be creating my own version the day after, so for now you can check Aasu’s work at the link provided.


