WeCodeAcademy

Writing Good Prompts

A prompt is the text you give an AI model. Clear prompts get better results. A reliable pattern:

  • Role: who the model should act as.
  • Task: exactly what to do.
  • Context: the facts it needs, because it only knows what you tell it.
  • Format: how the answer should look (length, list, table).

Compare "Tell me about farming" with "You are an agriculture adviser. List three low-cost ways a smallholder cassava farmer in Ghana can reduce post-harvest losses. Answer as a numbered list, one sentence each." The second leaves far less to chance.

Examplepython
Open in editor »
Quick check

Which addition most improves the prompt "Write a report"?

Your turn: write the code

Build a prompt for the role 'a maths tutor' with the task 'Explain fractions', the context 'The student is 10 years old' and the format 'Three short sentences', and print it.

Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.

Tip: use the left and right arrow keys to move between lessons.