# Prompt Engineering — Quiz

## Question 1

Which component of a prompt sets the AI's persona and expertise?

A) Context
B) Task
C) Role
D) Format

<!-- ANSWER: C -->
<!-- EXPLANATION: Role sets who the AI is (e.g., "You are an expert Python developer"). Context provides background; Task is the request; Format defines output structure. -->

## Question 2

Few-shot prompting improves output most for:

A) Simple translation
B) Structured or style-sensitive tasks where the pattern matters
C) Very long documents
D) Questions with a single correct answer

<!-- ANSWER: B -->
<!-- EXPLANATION: Few-shot gives examples so the model learns the pattern. It helps when format, style, or edge-case handling matters. Simple translation often works with zero-shot. -->

## Question 3

Chain-of-thought prompting is most useful for:

A) Short factual answers
B) Logic, math, and multi-step reasoning tasks
C) Creative writing
D) Summarization only

<!-- ANSWER: B -->
<!-- EXPLANATION: CoT asks the model to "think step by step," which improves performance on reasoning, logic, and multi-step problems. It reduces errors by surfacing intermediate reasoning. -->

## Question 4

For extracting structured data (e.g., names, dates) from text, you should request:

A) Freeform prose
B) JSON or XML with specified keys
C) Markdown only
D) Bullet points

<!-- ANSWER: B -->
<!-- EXPLANATION: Structured output (JSON, XML) with specified keys makes the output machine-readable and parseable. Freeform prose requires extra parsing; structured format enables integration. -->

## Question 5

Low temperature (0–0.3) is best for:

A) Brainstorming creative ideas
B) Factual extraction, code generation, classification
C) Varied storytelling
D) Open-ended exploration

<!-- ANSWER: B -->
<!-- EXPLANATION: Low temperature makes output deterministic and consistent — good for factual tasks, code, extraction. High temperature increases variety and creativity but also randomness. -->

## Question 6

A prompt produces generic, off-topic output. The best first fix is usually:

A) Add more constraints
B) Add context and be more specific about the task
C) Increase temperature
D) Use a different model

<!-- ANSWER: B -->
<!-- EXPLANATION: Generic output often means insufficient context or vague task. Adding context and specificity usually helps before adding constraints. Temperature and model choice come later if needed. -->

## Question 7

<!-- VISUAL: drag-order -->

Put these steps in the correct order for improving a vague prompt:

A) Add few-shot examples if the format matters
B) Define the role and context
C) Specify the output format (JSON, markdown, etc.)
D) Refine the task with concrete requirements

<!-- ANSWER: B,D,C,A -->
<!-- EXPLANATION: Start with role and context (B) to ground the AI. Then refine the task with specifics (D). Define output format (C) for parseability. Add examples (A) if style or structure is critical. -->

## Question 8

<!-- VISUAL: fill-blank -->

Complete the prompt template for structured extraction:

```
You are a ___0___ assistant. Extract the following from the text:
- name
- date
- amount

Return valid JSON with keys: name, date, amount.
```

<!-- ANSWER: data extraction -->
<!-- EXPLANATION: The template sets role (data extraction assistant), defines the task (extract specific fields), and specifies output format (JSON with keys). "data extraction" or "structured data" fits the role. -->
