Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to display the text "Hello, World!" in PowerShell.
PowerShell
Write-[1] "Hello, World!"
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using Write-Output instead of Write-Host for direct console display.
Misspelling the command name.
Using commands that do not exist in PowerShell.
✗ Incorrect
The Write-Host command in PowerShell prints text directly to the console.
2fill in blank
mediumComplete the code to store the number 5 in a variable named $num.
PowerShell
$num = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Putting the number inside quotes, which makes it a string.
Using invalid variable names like $5.
Writing the number as a word instead of a digit.
✗ Incorrect
In PowerShell, to assign a number to a variable, just use the number without quotes.
3fill in blank
hardFix the error in the code to correctly display the value of $name variable.
PowerShell
Write-Host [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting the $ sign before the variable name.
Putting the variable name inside quotes which prints the literal text.
Using single quotes which do not expand variables.
✗ Incorrect
To display the value of a variable, you must use the variable name with the $ sign.
4fill in blank
hardFill both blanks to create a loop that prints numbers 1 to 3.
PowerShell
for ($i = 1; $i [1] 3; $i[2]) { Write-Host $i }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-lt' instead of '-le' causing the loop to stop early.
Using '--' which decreases the counter instead of increasing.
Using incorrect operators causing syntax errors.
✗ Incorrect
The loop runs while $i is less than or equal to 3, and increments $i by 1 each time.
5fill in blank
hardFill all three blanks to create a hashtable with keys 'Name' and 'Age' and print the 'Name'.
PowerShell
$person = @{ [1] = 'John'; [2] = 30 }`nWrite-Host $person.[3] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using quotes around keys in the hashtable.
Accessing the hashtable with wrong key names.
Mixing up keys when printing the value.
✗ Incorrect
The hashtable keys are 'Name' and 'Age'. To print the name, access $person.Name.