Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to generate text using a GenAI model.
Prompt Engineering / GenAI
generated_text = model.[1](prompt) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' instead of 'generate' because 'predict' is for classification.
✗ Incorrect
The generate method is used to create new text based on the prompt.
2fill in blank
mediumComplete the code to load a pretrained GenAI image model.
Prompt Engineering / GenAI
image_model = GenAIImageModel.[1]('pretrained-model')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'train' which starts training instead of loading.
✗ Incorrect
The load method loads a pretrained model for use.
3fill in blank
hardFix the error in the code to generate audio from text.
Prompt Engineering / GenAI
audio_output = audio_model.[1](text_input) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'predict' which is for classification, not audio generation.
✗ Incorrect
The synthesize method converts text into audio output.
4fill in blank
hardFill both blanks to create a code snippet that generates code from a prompt and runs it.
Prompt Engineering / GenAI
generated_code = code_model.[1](prompt) exec([2])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'run' as a method on the model, which does not exist.
✗ Incorrect
Use generate to create code, then exec(generated_code) to run it.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps audio clips to their durations if duration is greater than 5 seconds.
Prompt Engineering / GenAI
audio_durations = {clip: [1] for clip in audio_clips if [2] > [3] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'len(clip)' which may not represent duration.
✗ Incorrect
Use clip.duration to get duration, and filter clips with duration > 5 seconds.