Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if variable $a equals 10.
PowerShell
if ($a [1] 10) { Write-Output 'Equal' }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -ne instead of -eq causes the condition to be true when values are not equal.
✗ Incorrect
The -eq operator checks if two values are equal.
2fill in blank
mediumComplete the code to check if $b is not equal to 5.
PowerShell
if ($b [1] 5) { Write-Output 'Not equal' }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -eq instead of -ne will give the opposite result.
✗ Incorrect
The -ne operator checks if two values are not equal.
3fill in blank
hardFix the error in the code to check if $num is greater than 100.
PowerShell
if ($num [1] 100) { Write-Output 'Greater' }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -lt will check for less than, which is the opposite.
✗ Incorrect
The -gt operator means 'greater than'.
4fill in blank
hardFill both blanks to check if $x is less than 50 and not equal to 20.
PowerShell
if (($x [1] 50) -and ($x [2] 20)) { Write-Output 'Valid' }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up -eq and -ne operators.
✗ Incorrect
Use -lt for 'less than' and -ne for 'not equal'.
5fill in blank
hardFill all three blanks to create a dictionary with keys as $word uppercase, values as $count, filtering counts greater than 10.
PowerShell
$result = @{ [1] = [2] } | Where-Object { $_.Value [3] 10 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using -lt instead of -gt will filter wrong values.
✗ Incorrect
Use $word.ToUpper() as key, $count as value, and -gt to filter counts greater than 10.