0
0
Prompt Engineering / GenAIml~10 mins

Iterative prompt refinement in Prompt Engineering / GenAI - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to add a new instruction to the prompt list.

Prompt Engineering / GenAI
prompt_steps = ['Describe the image']
prompt_steps.append([1])
Drag options to blanks, or click blank then click option'
A'Summarize the text'
B'Add more details'
C'Translate to French'
D'Generate a title'
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing a step unrelated to refining the prompt.
Using a step that changes the task instead of refining.
2fill in blank
medium

Complete the code to update the prompt with the latest refinement.

Prompt Engineering / GenAI
current_prompt = 'Describe the image'
refinement = 'Add color details'
updated_prompt = current_prompt + [1] + refinement
Drag options to blanks, or click blank then click option'
A'; '
B' and then '
C' - '
D' plus '
Attempts:
3 left
💡 Hint
Common Mistakes
Using a separator that is too informal or unclear.
Not using any separator causing prompt parts to merge.
3fill in blank
hard

Fix the error in the code that applies a refinement function to the prompt.

Prompt Engineering / GenAI
def refine_prompt(prompt):
    return prompt.lower()

prompt = 'Describe the Image'
refined = [1](prompt)
Drag options to blanks, or click blank then click option'
Arefine_prompt
BrefinePrompt
Crefineprompt
Drefine_prompt()
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect function name casing.
Not calling the function properly.
4fill in blank
hard

Fill both blanks to create a loop that applies multiple refinements to a prompt.

Prompt Engineering / GenAI
prompt = 'Describe the scene'
refinements = ['Add lighting', 'Include objects']
for [1] in [2]:
    prompt += '; ' + [1]
Drag options to blanks, or click blank then click option'
Arefinement
Brefinements
Cstep
Dsteps
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same name for loop variable and list.
Using undefined variable names.
5fill in blank
hard

Fill all three blanks to build a dictionary of prompt versions with their lengths.

Prompt Engineering / GenAI
prompts = ['Describe the sky', 'Add stars', 'Include moon']
prompt_lengths = { [1]: len([2]) for [3] in prompts }
Drag options to blanks, or click blank then click option'
Ap
Dprompt
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names causing errors.
Using undefined variables in the comprehension.