Challenge - 5 Problems
PowerShell Comparison Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate2:00remaining
What is the output of this PowerShell comparison?
Consider the following PowerShell code snippet. What will it output?
PowerShell
$a = 5 $b = 10 if ($a -lt $b) { "Less" } else { "Not Less" }
Attempts:
2 left
💡 Hint
Remember that -lt means 'less than'.
✗ Incorrect
Since 5 is less than 10, the condition $a -lt $b is true, so the output is 'Less'.
💻 Command Output
intermediate2:00remaining
What does this script print?
What will this PowerShell script print to the console?
PowerShell
$x = 7 $y = 7 if ($x -ne $y) { "Different" } else { "Same" }
Attempts:
2 left
💡 Hint
The -ne operator means 'not equal'.
✗ Incorrect
Since $x and $y are both 7, $x -ne $y is false, so the else block runs and prints 'Same'.
💻 Command Output
advanced2:00remaining
What is the output of this comparison chain?
What will this PowerShell code output?
PowerShell
$num = 15 if ($num -gt 10 -and $num -lt 20) { "In range" } else { "Out of range" }
Attempts:
2 left
💡 Hint
Check if 15 is greater than 10 and less than 20.
✗ Incorrect
15 is greater than 10 and less than 20, so the condition is true and 'In range' is printed.
💻 Command Output
advanced2:00remaining
What error or output does this script produce?
What happens when you run this PowerShell code?
PowerShell
$val = '5' if ($val -gt 3) { "Greater" } else { "Not Greater" }
Attempts:
2 left
💡 Hint
PowerShell tries to convert strings to numbers when comparing.
✗ Incorrect
PowerShell converts the string '5' to number 5, which is greater than 3, so it prints 'Greater'.
💻 Command Output
expert3:00remaining
What is the output of this script with mixed comparisons?
Analyze this PowerShell script and select the output it produces.
PowerShell
$a = 8 $b = 8 $c = 10 if ($a -eq $b -and $c -lt 5) { "Match and less" } elseif ($a -eq $b -and $c -gt 5) { "Match and greater" } else { "No match" }
Attempts:
2 left
💡 Hint
Check both conditions carefully in order.
✗ Incorrect
The first if condition fails because $c -lt 5 is false. The elseif condition is true because $a equals $b and $c is greater than 5, so it prints 'Match and greater'.