Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a double-quoted string that supports variable interpolation.
PowerShell
$name = 'Alice' $message = [1]"Hello, $name!"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which do not interpolate variables.
Using backticks which are escape characters, not string delimiters.
✗ Incorrect
Double quotes " " allow variable interpolation in PowerShell strings, so $name will be replaced by its value.
2fill in blank
mediumComplete the code to create a here-string that preserves line breaks.
PowerShell
$text = @[1]
This is line one.
This is line two.
@ Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes @' which create literal strings without variable interpolation.
Using triple quotes which are not valid in PowerShell.
✗ Incorrect
Here-strings in PowerShell start with @" and end with "@ to preserve formatting and line breaks.
3fill in blank
hardFix the error in the string interpolation to correctly include the variable value.
PowerShell
$count = 5 Write-Output "You have [1] items."
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which prevent interpolation.
Using backtick which escapes the dollar sign instead of interpolating.
✗ Incorrect
Using ${count} inside double quotes ensures the variable name is clearly delimited for interpolation.
4fill in blank
hardFill both blanks to create a string that includes a variable and a calculated expression.
PowerShell
$price = 10 $quantity = 3 $total = [1]"Total cost: $[2]"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes which prevent interpolation.
Using addition instead of multiplication for total cost.
✗ Incorrect
Double quotes allow interpolation, and using ${price * quantity} calculates the total inside the string.
5fill in blank
hardFill all three blanks to create a here-string with variable interpolation and a newline.
PowerShell
$user = 'Bob' $message = @[1] Hello, $[2]! Welcome to the system. [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using single quotes '@ which create literal strings without interpolation.
Forgetting to close the here-string properly.
✗ Incorrect
Here-strings start with @" and end with "@ for interpolation; $user is referenced inside the string.