Step-by-Step Prompting
Asking the AI to work through a problem in steps often gives more accurate answers on maths, logic and planning tasks.
Why Steps Help
A language model writes one token at a time. If it jumps straight to the final answer, it has no "space" to work things out. When it writes the steps first, each step helps the next one. This idea is often called chain-of-thought prompting.
Many modern models already reason internally before answering (sometimes called "thinking" or "reasoning" modes). Even then, asking for clear steps helps you check the work.
A Simple Example
Example
A shopkeeper buys 12 notebooks at Rs 85 each and sells them
at Rs 110 each. What is the total profit?
Work it out step by step, then give the final answer on its own line.The answer should show: cost = 12 x 85 = 1020, sales = 12 x 110 = 1320, profit = 1320 - 1020 = 300. You can check this yourself in Python:
Example
cost = 12 * 85
sales = 12 * 110
print("Cost:", cost)
print("Sales:", sales)
print("Profit:", sales - cost)Cost: 1020 Sales: 1320 Profit: 300
For important numbers, ask the AI to show its steps, then check with a calculator or code. Some chatbots can also run code themselves to do exact maths.
Breaking a Big Task into Steps
For big jobs, do not ask for everything in one prompt. Split the work into a chain of prompts, where each answer feeds the next:
| Step | Prompt |
|---|---|
| 1 | "List 5 possible topics for a blog post about saving electricity in Pakistani homes." |
| 2 | "Make an outline for topic 3 with 5 headings." |
| 3 | "Write the section under heading 1 in 120 words." |
| 4 | "Review the full post for clarity and suggest 3 improvements." |
Each step is easier to check and fix than one huge answer.
Prompt Chaining in Code
Developers do the same thing in programs. Here each "step" is a function, and the output of one goes into the next. (The functions are fake stand-ins for real AI calls.)
Example
def step_outline(topic):
return [f"Why {topic} matters", f"Simple ways to save on {topic}", "Summary"]
def step_write(heading):
return f"## {heading}\n(short paragraph about {heading.lower()})"
outline = step_outline("electricity")
for heading in outline:
print(step_write(heading))## Why electricity matters (short paragraph about why electricity matters) ## Simple ways to save on electricity (short paragraph about simple ways to save on electricity) ## Summary (short paragraph about summary)
Asking the AI to Plan First
Before a complex task, ask for a plan and approve it:
Example
I need to build a simple website for my tuition centre.
First, give me a step-by-step plan with no code.
Wait for my approval before writing any code.Asking the AI to Check Itself
After an answer, a second prompt can catch mistakes:
Example
Check your previous answer. List any calculation errors or
missing steps. If everything is correct, say "No errors found."Exercise
Exercise
Why is splitting a big task into a chain of smaller prompts helpful?
