Prompt Engineering9 min read

What is Prompting?

Talk to AI like a pro β€” the art of asking the right question
scope:Foundationaldifficulty:Beginner

Ordering Food in a Foreign Country

Imagine you're in a restaurant in a country where you barely speak the language. You're starving. You have two options:

Option A: You point vaguely at the menu and say "Food, please."

Option B: You carefully say "I'd like a medium-rare ribeye steak with mashed potatoes and steamed broccoli, no butter on the vegetables."

With Option A, you might get anything β€” sushi, soup, a salad, or something you're allergic to. With Option B, you get exactly what you want.

Talking to AI works the exact same way. The instructions you give to an AI are called a prompt, and the quality of what you get back depends almost entirely on how well you write that prompt.

What Exactly is a Prompt?

A prompt is simply the text you type into an AI system. That's it. Every message you send to ChatGPT, Claude, Gemini, or any other AI β€” that's a prompt.

But here's what most people don't realize: the AI doesn't "understand" your intent the way a human would. It doesn't read between the lines. It doesn't know what you meant to ask. It only has the exact words you typed.

This means:

  • A vague prompt gets a vague answer
  • An ambiguous prompt gets a random interpretation
  • A specific, clear prompt gets a specific, useful answer

Good Prompts vs Bad Prompts

Let's see the difference with real examples:

  • Bad: Tell me about Python β€” Are you asking about the snake or the programming language? A 5-minute overview or a PhD-level deep dive?
  • Good: Explain Python list comprehensions with 3 simple examples. Assume I know basic Python but am new to comprehensions.
  • Bad: Write an email β€” To whom? About what? What tone? How long?
  • Good: Write a polite 3-sentence email to my professor requesting a one-week extension on the homework due Friday. Mention that I've been sick.
  • Bad: Help with my code β€” What code? What language? What's the problem?
  • Good: My Python function is supposed to return the largest number in a list but returns None for empty lists. Here's the code: [paste code]. How do I fix it?
Note: The Golden Rule of Prompting: If a smart human would need to ask you a follow-up question to understand your request, your prompt isn't specific enough. Give the AI all the context it needs in the first message.

The Five Elements of a Great Prompt

Great prompts usually include some combination of these elements:

  • Task β€” What do you want the AI to do? ("Explain", "Write", "Compare", "Debug", "Translate")
  • Context β€” What background information does the AI need? ("I'm a beginner", "This is for a business presentation", "The audience is 10-year-olds")
  • Format β€” How should the output look? ("As a bullet list", "In a table", "In 3 paragraphs", "As Python code")
  • Tone β€” What style should the response have? ("Professional", "Casual", "Funny", "Academic")
  • Constraints β€” What limits or rules apply? ("Under 100 words", "Don't use technical jargon", "Include exactly 5 examples")

You don't need all five every time. But the more you include, the better your results.

The Magic of Being Specific

Watch how adding specificity transforms results:

  • Level 1: Write a story β†’ generic, bland, unpredictable
  • Level 2: Write a short story about a dog β†’ better, but still vague
  • Level 3: Write a 200-word children's story about a golden retriever named Biscuit who is afraid of thunder but discovers that thunder is just clouds clapping β†’ specific, creative, delightful

Each level of specificity gives the AI more to work with. It's not about writing long prompts β€” it's about writing clear prompts with the right details.

Prompt Engineering in Practice

# Demonstrating how prompt quality affects AI output
# (Using a hypothetical AI function for illustration)
def simulate_ai_response(prompt):
"""Simulate how AI quality scales with prompt quality."""
# Count specificity signals in the prompt
specificity = 0
signals = [
'example', 'format', 'tone', 'audience', 'length',
'step', 'list', 'table', 'beginner', 'expert',
'don\'t', 'include', 'avoid', 'exactly', 'assume'
]
for signal in signals:
if signal.lower() in prompt.lower():
specificity += 1
# Rate the prompt
if specificity == 0:
quality = "Vague β€” AI will guess what you want"
elif specificity <= 2:
quality = "Decent β€” AI has some direction"
elif specificity <= 4:
quality = "Good β€” AI knows what you need"
else:
quality = "Excellent β€” AI can nail this"
return quality, specificity
# Compare prompts
prompts = [
"Tell me about sorting",
"Explain bubble sort with an example",
"Explain bubble sort step by step for a beginner. "
"Include a Python example with a list of 5 numbers. "
"Format the explanation as a numbered list.",
]
print("=== Prompt Quality Analyzer ===")
for i, prompt in enumerate(prompts, 1):
quality, score = simulate_ai_response(prompt)
print(f"\nPrompt {i}: \"{prompt[:60]}{'...' if len(prompt) > 60 else ''}\"")
print(f" Specificity signals: {score}")
print(f" Rating: {quality}")
# The five elements of a great prompt
print("\n=== Building a Great Prompt ===")
elements = {
"Task": "Explain bubble sort",
"Context": "for a beginner programmer",
"Format": "as a numbered step-by-step list",
"Tone": "friendly and encouraging",
"Constraints": "under 200 words, include one code example",
}
full_prompt = ". ".join(f"{v}" for v in elements.values())
print("\nElement breakdown:")
for element, text in elements.items():
print(f" {element:>12}: {text}")
print(f"\nCombined prompt: \"{full_prompt}.\"")
Output
=== Prompt Quality Analyzer ===

Prompt 1: "Tell me about sorting"
  Specificity signals: 0
  Rating: Vague β€” AI will guess what you want

Prompt 2: "Explain bubble sort with an example"
  Specificity signals: 1
  Rating: Decent β€” AI has some direction

Prompt 3: "Explain bubble sort step by step for a beginner. Include ..."
  Specificity signals: 5
  Rating: Excellent β€” AI can nail this

=== Building a Great Prompt ===

Element breakdown:
          Task: Explain bubble sort
       Context: for a beginner programmer
        Format: as a numbered step-by-step list
          Tone: friendly and encouraging
   Constraints: under 200 words, include one code example

Combined prompt: "Explain bubble sort. for a beginner programmer. as a numbered step-by-step list. friendly and encouraging. under 200 words, include one code example."

Iteration: Your Secret Weapon

Here's something that surprises people: great prompts rarely come out perfect the first time. The best AI users don't write one prompt and accept whatever comes back. They iterate.

The process looks like this:

  • Step 1: Write your best prompt and send it
  • Step 2: Look at what the AI gave you. What's good? What's wrong?
  • Step 3: Refine your prompt based on what was missing. "That's good, but make it shorter" or "Use simpler words" or "Add more examples"
  • Step 4: Repeat until you get what you need

This is how professionals use AI. They don't expect perfection on the first try. They have a conversation, guiding the AI closer and closer to what they want.

Think of it like giving directions. If someone ends up on the wrong street, you don't start over β€” you say "Turn around, go two blocks east." Same with AI. Build on what it gave you.

Challenge

Quick check

What is a 'prompt' in the context of AI?

Continue reading