Refining a prompt after reviewing the output

Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.

Refining a prompt after reviewing the output

Name:
Date:
Class:

Quick Questions

Shade in the A or B circle for each question.

1. The AI's code uses names like MyScore and x. Which follow-up prompt is better?
A Rename the variables using snake_case, such as player_score.
B This code is bad. Try again.
2. The generated program accepts an age of -5. What should your follow-up prompt do?
A Ask the AI to make the program better.
B Ask for range checking so age must be between 0 and 120.
3. You review AI code and find it has no comments. Which follow-up prompt is best?
A Add a comment above each function explaining its purpose.
B Fix the code.
4. True or false: after you spot a problem in generated code, a follow-up prompt should name that problem.
A False
B True
5. The AI gives two different versions of your code. What is the best next step?
A Compare both versions against your requirements, then refine your prompt.
B Use the shorter one without testing it.

Match the Pairs

Draw a line connecting each item on the left to its match on the right.

Left columnRight column
1Use snake_case names for all variables ANo specific request for names, validation or comments. Replace with 'Use camelCase names and add comments to each loop'.
2Add range checking so age must be 0 to 120 BKeep version B's validation but use version A's variable names
3After reviewing output that has no comments, refine the prompt to ask for explanations of the code CA follow-up prompt that asks the AI to add validation with clear limits
4Comparing two generated versions, then refining the prompt to keep the better features of both DToo vague: it does not name the problem, so the AI has to guess what to change. Say what is wrong, e.g. 'Add range checking to the age input'.
5Prompt: Fix it, it is wrong EAdd a comment above each function explaining what it does
6Prompt: Make the code better and nicer FA follow-up prompt that asks the AI to apply a naming convention to the generated code

Definitions

follow-up prompt

Fill in the Blanks

Complete each line of code by filling in the missing parts.

1.
prompt = "Use __________ for all variables"
2.
followup = "Add _____ checking to age"
3.
followup = "Add a _______ above each loop"
4.
if scoreB _ scoreA: best = "B"
5.
problem = "age accepts negative numbers" followUp = "Fix this: " _ problem

Spot the Error

Shade in the letter of the line that contains an error.

Question 1
A # Follow-up: use camelCase names
B total_marks = 0
C for mark_value in marks_list:
D total_marks += mark_value
Question 2
A age = int(input('Age: '))
B # Follow-up: add range checking
C while age < 0 and age > 120:
D age = int(input('Age: '))
Question 3
A total = sum(marks)
B # Find the highest mark
C average = total / len(marks)
D print(average)
Question 4
A # v2: adds range checking
B def check_mark(mark):
C if mark < 0 or mark > 100:
D return True
E return True
Question 5
A # Follow-up: use snake_case
B def calc_total(price, qty):
C total_cost = price * qty
D return totalCost

Answer Key

Refining a prompt after reviewing the output
Section A: Quick Questions
Q1
A — Rename the variables using snake_case, such as player_score.
Q2
B — Ask for range checking so age must be between 0 and 120.
Q3
A — Add a comment above each function explaining its purpose.
Q4
B — True
Q5
A — Compare both versions against your requirements, then refine your prompt.
Section B: Match the Pairs
Q1
Use snake_case names for all variables → A follow-up prompt that asks the AI to apply a naming convention to the generated code
Q2
Add range checking so age must be 0 to 120 → A follow-up prompt that asks the AI to add validation with clear limits
Q3
After reviewing output that has no comments, refine the prompt to ask for explanations of the code → Add a comment above each function explaining what it does
Q4
Comparing two generated versions, then refining the prompt to keep the better features of both → Keep version B's validation but use version A's variable names
Q5
Prompt: Fix it, it is wrong → Too vague: it does not name the problem, so the AI has to guess what to change. Say what is wrong, e.g. 'Add range checking to the age input'.
Q6
Prompt: Make the code better and nicer → No specific request for names, validation or comments. Replace with 'Use camelCase names and add comments to each loop'.
Section C: Definitions
Q1
follow-up prompt — A new prompt sent after reviewing AI code that names the exact problem, e.g. 'Use snake_case names and add range checking', so the next version fixes it.
Section D: Fill in the Blanks
Q1
prompt = "Use snake_case for all variables"
Q2
followup = "Add range checking to age"
Q3
followup = "Add a comment above each loop"
Q4
if scoreB > scoreA: best = "B"
Q5
problem = "age accepts negative numbers" followUp = "Fix this: " + problem
Section E: Spot the Error
Q1
A — The follow-up prompt asked for snake_case names and the code uses snake_case. The comment should say 'use snake_case names', not camelCase.
Q2
C — No number is both below 0 and above 120, so the loop never runs and the range check does nothing. It should use 'or' to catch invalid ages.
Q3
B — When you ask the AI for comments, they must match what the code does. This code works out the average, so the comment should say 'Find the average mark'.
Q4
D — Version 2 was refined to add range checking, so an out-of-range mark must return False. Returning True accepts invalid marks, so the check has no effect.
Q5
D — The variable was created as total_cost. totalCost is a different name that does not exist, so it causes a NameError and also breaks the snake_case convention. It should be 'return total_cost'.