0
0
Prompt Engineering / GenAIml~10 mins

Prompt templates and variables 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 define a prompt template with a variable placeholder.

Prompt Engineering / GenAI
prompt = "Hello, [1]! Welcome to AI."
Drag options to blanks, or click blank then click option'
A{name}
B{input}
C{user}
D{variable}
Attempts:
3 left
💡 Hint
Common Mistakes
Using plain text without curly braces.
Using a variable name that doesn't match the context.
2fill in blank
medium

Complete the code to insert a variable into the prompt template using f-string syntax.

Prompt Engineering / GenAI
name = "Alice"
prompt = f"Hello, [1]! How are you?"
Drag options to blanks, or click blank then click option'
A{name}
B{user}
C{input}
D{variable}
Attempts:
3 left
💡 Hint
Common Mistakes
Using placeholders like {user} instead of the actual variable name.
Not using f-string syntax.
3fill in blank
hard

Fix the error in the prompt template by correctly formatting the variable placeholder.

Prompt Engineering / GenAI
prompt = "Your input is: [1]".format(input)
Drag options to blanks, or click blank then click option'
A{}
B{input}
C{value}
D{0}
Attempts:
3 left
💡 Hint
Common Mistakes
Using named placeholders without passing named arguments.
Using empty braces {} without arguments.
4fill in blank
hard

Fill both blanks to create a prompt template that uses named variables with format().

Prompt Engineering / GenAI
prompt = "Hello, [1]! Your score is [2].".format([1]="Alice", [2]=95)
Drag options to blanks, or click blank then click option'
Aname
Bscore
Cuser
Dvalue
Attempts:
3 left
💡 Hint
Common Mistakes
Mismatch between placeholder names and format argument names.
Using positional placeholders with named arguments.
5fill in blank
hard

Fill all three blanks to build a prompt template using f-string with multiple variables.

Prompt Engineering / GenAI
user = "Bob"
score = 88
prompt = f"Hello, [1]! Your score is [2] out of [3]."
Drag options to blanks, or click blank then click option'
Auser
Bscore
C100
Dtotal
Attempts:
3 left
💡 Hint
Common Mistakes
Using undefined variable names.
Putting variables inside quotes inside f-string.