Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a variable that stores a user's name.
LangChain
user_name = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around text
Using variable names instead of text
✗ Incorrect
Variables that store text must be enclosed in quotes.
2fill in blank
mediumComplete the code to insert a variable into a prompt string using f-string syntax.
LangChain
prompt = f"Hello, [1]! How can I help you today?"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around the variable inside the f-string
Using a different variable name than defined
✗ Incorrect
Inside an f-string, variables are used without quotes to insert their values.
3fill in blank
hardFix the error in the code to correctly create a prompt with dynamic content.
LangChain
prompt = f"Your order number is [1]."
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around the variable name
Using a variable name with invalid characters
✗ Incorrect
The variable name must match exactly and be used without quotes inside the f-string.
4fill in blank
hardFill both blanks to create a dictionary with variable keys and values.
LangChain
data = { [1]: [2] } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using variables without quotes as keys
Using numbers without quotes when strings are needed
✗ Incorrect
Dictionary keys as strings need quotes, and values can be strings too.
5fill in blank
hardFill all three blanks to create a prompt template with variables and a condition.
LangChain
prompt = f"Hello, [1]! Your balance is [2]. [3]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting quotes around variable names inside the f-string
Forgetting to quote the message string
✗ Incorrect
Use variables user_name and balance inside the f-string, and add a message as a string.