GH-300 - Apply prompt engineering and context crafting - Section 4.2

Apply zero-shot and few-shot prompting and prompt-crafting best practices.

Apply zero-shot and few-shot prompting, choose between them for a task, and follow prompt-crafting best practices: be specific, provide examples, give the model a role, and break a large request into steps. Recognise the prompt patterns that produce better Copilot output.

Zero-shot promptingFew-shot promptingPrompt best practicesExamples in prompts

Practice question for this objective

Free sampleApply prompt engineering and context craftingmedium

A developer is choosing between zero-shot and few-shot prompting for two separate Copilot Chat tasks. They want to reserve few-shot prompting for the cases where worked examples genuinely earn their place in the prompt. In which situations does adding examples to the prompt most justify a few-shot approach? Select TWO.

  • AThe task must produce output in a strict in-house shape, such as a bespoke log line whose field order and bracket style the model keeps getting subtly wrong from a plain instruction. Correct
  • BThe task is classifying tickets into company-specific categories whose names and boundaries are not standard terms, and a plain instruction keeps placing items in the wrong category. Correct
  • CThe task is converting a Celsius value to Fahrenheit using one well-known formula, where a single plain instruction already produces the correct result without any demonstration.
  • DThe task is so large that it must be split into a sequence of refining Chat prompts, because few-shot prompting is the mechanism that breaks a feature into ordered steps.
  • EThe task needs the answer verified against authoritative sources, since adding examples is the recognised way to make Copilot confirm versions and rate limits are current.
Few-shot prompting earns its cost when output must match a bespoke shape or use company-specific categories the model cannot infer from words alone. Worked examples are worth their token cost when the model cannot infer the target from a plain instruction: a bespoke output format and non-standard, company-specific categories both fall into this gap, whereas a common formula is a clean zero-shot case and sequencing or verification are different concerns entirely.

Why A is correct: A bespoke output shape the model cannot infer from words is exactly what worked examples lock in, so demonstrating the format earns the few-shot cost.

Why B is correct: Non-standard categories the model has no prior notion of are clarified by labelled examples that show each category's boundary, which a plain instruction cannot convey.

Why C is wrong: This is tempting because any task can take examples, but a common formula the model already knows is the textbook zero-shot case, so examples add cost without benefit.

Why D is wrong: This conflates techniques; decomposing a feature into ordered steps is iterative prompting, not few-shot, which is about supplying examples rather than sequencing work.

Why E is wrong: This misattributes a safeguard to a technique; examples shape output form and never verify currency, which remains a manual check against authoritative sources.

See more GH-300 practice questions, answers explained.

More in this domain

Back to all Apply prompt engineering and context crafting objectives, or the GH-300 cert hub.

Examworthy is not affiliated with or endorsed by GitHub. Original, blueprint-aligned practice material only.