Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 38 ยท Getting Started

What Is Prompt Engineering?

Learn what prompt engineering is, why the way you phrase a request changes a language model's answer, and how this course teaches it with runnable Python.

A prompt is the input you give a language model: a question, an instruction, a document, a few examples, or all of those together. Prompt engineering is the practice of designing that input so the model produces the output you actually need, reliably and at a reasonable cost. It is part writing, part testing, and part software design.

If you have ever typed "summarize this" into a chatbot and gotten something too long, too vague, or in the wrong format, you have already felt the problem. The model did not misbehave. It answered the request it received, and the request left a lot open. Prompt engineering is the skill of closing those gaps on purpose.

Honest note about this course. Large language models cannot run inside this website, and we do not call any paid API from your browser. Every runnable example here uses Python in your browser to do the parts that are really code: building prompts, filling templates, counting tokens, validating JSON, scoring outputs, and simulating a model with a tiny stand-in. Each stand-in is labelled. Whenever we show what a real model might answer, it is a static, illustrative sample (not live output), and real models will vary.

Why wording matters

A language model predicts text one piece at a time, conditioned on everything in the prompt. Different prompts put the model in different "situations", so the likely continuations differ. Compare two requests for the same task.

TEXT
Prompt A:
Tell me about our refund policy email.

Prompt B:
Rewrite the email below for a customer who is angry about a late delivery.
Keep it under 90 words, apologize once, offer a refund or a replacement,
and end with a single clear next step.

Email:
"""
Your order shipped late. Refunds take 5-7 days.
"""

Prompt A could mean "summarize", "critique", "write", or "explain". Prompt B names the task, the audience, the constraints, and gives the source text. You would expect B to be far more predictable. That predictability, not cleverness, is what you are engineering.

What prompt engineering is not

  • It is not magic words. Phrases like "take a deep breath" sometimes help a particular model on a particular task, but you should measure it, not assume it.
  • It is not a replacement for software. Anything you can do with plain code (parsing, math, lookups) usually belongs in code. Prompts handle the fuzzy parts: understanding, rewriting, classifying, reasoning over text.
  • It is not one-and-done. A prompt is a piece of source code. It has versions, tests, and bugs.

The prompt engineering loop

Good prompts come from a loop, the same way good programs do.

flowchart LR
  A["Define the task<br/>and what 'good' means"] --> B["Draft a prompt"]
  B --> C["Run it on<br/>several test inputs"]
  C --> D["Compare outputs<br/>to the goal"]
  D -->|"fails"| E["Change one thing"]
  E --> C
  D -->|"passes"| F["Save the version<br/>and keep testing"]

The loop you will repeat throughout the course: define, draft, run, compare, adjust.

Notice step one. Before you write a single word of a prompt, you decide what a good answer looks like. Without that, you cannot tell whether a change helped.

Your first runnable prompt tool

Prompts are text, and text is something Python handles well. The first exercise treats a prompt as a template with named slots, which is how real applications build prompts. (Nothing here calls a model; it just builds the string you would send.)

Python A prompt is a string you build

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Change max_words or company and run it again. Every real prompting system, from a chatbot to a document pipeline, is some version of this: fixed instructions plus variable data.

A stand-in model you can poke at

To make the loop concrete without a real model, the next block defines a toy stand-in called fake_model. It is not intelligent. It follows a few keyword rules so you can see how a prompt's contents steer the output and how a vague prompt leaves the result unspecified.

Python Toy stand-in: vague vs specific prompts

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

A real model is far more flexible than these rules, but the lesson transfers: the more of the situation you state, the less the model has to guess.

Where prompts live in real products

Prompts are not only things people type into a chat window. They are embedded in software:

  • A system prompt that sets behavior for every conversation in an app.
  • A template that wraps each user's input in instructions.
  • A tool description that tells the model when to call a function.
  • A retrieval step that pastes relevant documents into the context.
  • An evaluation prompt that asks a model to grade another model's output.

You will meet each of these in this course. Chapters 1 to 4 (this part) cover the basics, fundamentals, techniques, and structured output. Later chapters cover retrieval, evaluation, safety, and production patterns.

Skills you will build

What you will learn

Write clearly Specific, testable instructions
Use techniques Examples, reasoning, roles
1 / 2

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What is prompt engineering?

    Prompt engineering is about designing, testing and refining the input, not changing the model itself.
  2. 2. Why is "Tell me about our refund policy email" a weak prompt?

    The task, audience and constraints are all left open, so the model has to guess what you want.
  3. 3. What should you do before writing a prompt?

    Without a definition of "good", you cannot tell whether a prompt change helped or hurt.
  4. 4. In this course, what do the runnable Python examples do?

    Real models do not run on this site, so the code handles the genuinely programmatic parts and uses clearly labelled stand-ins.

Summary

  • A prompt is the input to a model; prompt engineering is designing it for reliable results.
  • Vague prompts leave the task, audience and format open; specific prompts close those gaps.
  • Prompts are source code: define success, draft, test on several inputs, change one thing, repeat.
  • Python handles the programmatic parts (templates, validation, scoring); this course uses labelled stand-ins instead of real model calls.

Next: How Language Models Read Prompts