Bird
Raised Fist0
Prompt Engineering / GenAIml~20 mins

Iterative prompt refinement in Prompt Engineering / GenAI - Practice Problems & Coding Challenges

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Challenge - 5 Problems
🎖️
Iterative Prompt Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is iterative prompt refinement important in generative AI?

Consider you want to get the best answer from a generative AI model. Why do you need to refine your prompt step-by-step?

ABecause the model ignores the first prompt and only answers the last one.
BBecause the model learns from each prompt and updates itself automatically.
CBecause refining the prompt helps clarify the question and guides the model to produce better answers.
DBecause the model only understands very short prompts and needs multiple tries.
Attempts:
2 left
💡 Hint

Think about how clear instructions affect the quality of answers.

Predict Output
intermediate
1:30remaining
What is the output of this prompt refinement simulation?

Given the following Python code simulating prompt refinement scores, what is the final score printed?

Prompt Engineering / GenAI
scores = [0.5, 0.7, 0.85, 0.9]
final_score = scores[-1]
print(final_score)
A0.5
B0.7
C0.85
D0.9
Attempts:
2 left
💡 Hint

Look at the last item in the list.

Model Choice
advanced
2:30remaining
Which model is best suited for iterative prompt refinement tasks?

You want to refine prompts iteratively to generate detailed text answers. Which model type is most suitable?

AA small rule-based chatbot with fixed responses.
BA large language model trained on diverse text data with few-shot learning ability.
CA simple keyword matching model without context understanding.
DA model trained only on numerical data without language capabilities.
Attempts:
2 left
💡 Hint

Think about which model can understand and generate complex text.

Metrics
advanced
2:00remaining
Which metric best measures improvement during iterative prompt refinement?

When refining prompts to improve AI responses, which metric helps track progress effectively?

AUser satisfaction score or relevance rating of generated answers.
BModel training loss on unrelated data.
CNumber of words in the prompt.
DThe time taken to type the prompt.
Attempts:
2 left
💡 Hint

Consider what shows better quality in AI answers.

🔧 Debug
expert
2:30remaining
What error does this iterative prompt refinement code produce?

Examine the code below that tries to refine prompts and print the best one. What error occurs when running it?

Prompt Engineering / GenAI
prompts = ['Tell me a joke', 'Tell me a funny joke', 'Tell me a very funny joke']
best_prompt = None
best_score = 0
for prompt in prompts:
    score = len(prompt) / 0  # Simulate scoring
    if score > best_score:
        best_score = score
        best_prompt = prompt
print(best_prompt)
AZeroDivisionError
BIndexError
CNameError
DTypeError
Attempts:
2 left
💡 Hint

Look at the scoring line carefully.

Practice

(1/5)
1. What is the main goal of iterative prompt refinement when working with AI models?
easy
A. To avoid changing the prompt once it is written
B. To improve the prompt step-by-step for clearer AI answers
C. To write the longest possible prompt in one try
D. To use random words to confuse the AI

Solution

  1. Step 1: Understand the purpose of prompt refinement

    Iterative prompt refinement means making small changes to your prompt to get better AI responses.
  2. Step 2: Identify the goal of this process

    The goal is to improve clarity and usefulness of AI answers by adjusting the prompt step-by-step.
  3. Final Answer:

    To improve the prompt step-by-step for clearer AI answers -> Option B
  4. Quick Check:

    Iterative refinement = step-by-step improvement [OK]
Hint: Think: How do you get better answers? By improving prompts stepwise [OK]
Common Mistakes:
  • Thinking the prompt should never change
  • Believing longer prompts always work best
  • Assuming random words help AI understand
2. Which of the following is the correct way to start refining a prompt iteratively?
easy
A. Write a clear initial prompt and test AI response
B. Write a very long prompt with many unrelated details
C. Use only one word as a prompt
D. Never test the prompt before finalizing

Solution

  1. Step 1: Identify best practice for starting prompt refinement

    Start with a clear, simple prompt to see how AI responds.
  2. Step 2: Understand why testing matters

    Testing helps know what to improve next in the prompt.
  3. Final Answer:

    Write a clear initial prompt and test AI response -> Option A
  4. Quick Check:

    Start clear + test = best first step [OK]
Hint: Begin with clarity and test before changing [OK]
Common Mistakes:
  • Starting with confusing or too long prompts
  • Skipping testing before refining
  • Using too few words to explain
3. Given this initial prompt: "List fruits", after iterative refinement, which prompt is likely to get a better AI answer listing only tropical fruits?
medium
A. "List fruits"
B. "List all fruits and animals"
C. "Tell me about fruits and vegetables"
D. "List tropical fruits only"

Solution

  1. Step 1: Compare initial and refined prompts

    The initial prompt "List fruits" is broad and may list all fruits.
  2. Step 2: Identify which prompt narrows the request

    "List tropical fruits only" clearly asks for tropical fruits, refining the request.
  3. Final Answer:

    "List tropical fruits only" -> Option D
  4. Quick Check:

    Specific prompt = better targeted answer [OK]
Hint: Add specific details to focus AI answers [OK]
Common Mistakes:
  • Choosing too broad prompts
  • Mixing unrelated topics in prompt
  • Not specifying the desired subset
4. You wrote this prompt: "Explain AI" but the AI gives a very technical answer. What is the best fix using iterative prompt refinement?
medium
A. Use unrelated words like 'banana' in the prompt
B. Add more technical terms to the prompt
C. Change prompt to 'Explain AI in simple words for beginners'
D. Make the prompt shorter to just 'AI'

Solution

  1. Step 1: Identify the problem with the original prompt

    Original prompt is too broad, causing a technical answer that may be hard to understand.
  2. Step 2: Choose a refinement that clarifies the audience

    Adding 'in simple words for beginners' guides AI to simplify the explanation.
  3. Final Answer:

    Change prompt to 'Explain AI in simple words for beginners' -> Option C
  4. Quick Check:

    Clarify audience to simplify AI response [OK]
Hint: Specify audience or style to guide AI tone [OK]
Common Mistakes:
  • Adding unrelated words confuses AI
  • Making prompt too short loses context
  • Adding more technical terms worsens complexity
5. You want the AI to generate a list of 5 healthy breakfast ideas but it keeps giving snacks. Which iterative prompt refinement will best fix this?
hard
A. "List 5 healthy breakfast ideas only, no snacks"
B. "List 5 snacks and breakfast ideas"
C. "List any 5 food items"
D. "List 5 unhealthy breakfast ideas"

Solution

  1. Step 1: Identify the issue with the current AI output

    The AI includes snacks because the prompt is not specific enough to exclude them.
  2. Step 2: Refine the prompt to exclude snacks and focus on healthy breakfasts

    Adding 'only, no snacks' clearly tells AI to avoid snacks and focus on breakfast ideas.
  3. Final Answer:

    "List 5 healthy breakfast ideas only, no snacks" -> Option A
  4. Quick Check:

    Clear exclusions improve AI focus [OK]
Hint: Use clear exclusions to avoid unwanted answers [OK]
Common Mistakes:
  • Including snacks by not excluding them
  • Being too vague about food types
  • Requesting unhealthy options by mistake