Challenge - 5 Problems
PowerShell Logic 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 this PowerShell command:
What will be the output?
$result = 5 -gt 3
Write-Output $result
What will be the output?
PowerShell
$result = 5 -gt 3 Write-Output $result
Attempts:
2 left
💡 Hint
The '-gt' operator checks if the left value is greater than the right value.
✗ Incorrect
The '-gt' operator returns True if the left number is greater than the right number. Since 5 is greater than 3, the output is True.
💻 Command Output
intermediate2:00remaining
What does this logical operation output?
Look at this PowerShell code:
What will be printed?
$a = $true
$b = $false
$result = $a -and $b
Write-Output $result
What will be printed?
PowerShell
$a = $true $b = $false $result = $a -and $b Write-Output $result
Attempts:
2 left
💡 Hint
The '-and' operator returns True only if both sides are True.
✗ Incorrect
Since $a is True and $b is False, the '-and' operator returns False.
💻 Command Output
advanced2:00remaining
What is the output of this combined comparison and logic?
Analyze this PowerShell snippet:
What will it output?
$x = 10
$y = 20
$result = ($x -lt 15) -or ($y -eq 10)
Write-Output $result
What will it output?
PowerShell
$x = 10 $y = 20 $result = ($x -lt 15) -or ($y -eq 10) Write-Output $result
Attempts:
2 left
💡 Hint
The '-or' operator returns True if at least one side is True.
✗ Incorrect
Since $x is less than 15 (True), and $y equals 10 is False, the '-or' returns True.
💻 Command Output
advanced2:00remaining
What does this PowerShell code output?
Look at this code:
What happens when you run it?
$result = 5 -and 3
Write-Output $result
What happens when you run it?
PowerShell
$result = 5 -and 3 Write-Output $result
Attempts:
2 left
💡 Hint
In PowerShell, '-and' returns the last evaluated value if both are true-like.
✗ Incorrect
Both 5 and 3 are treated as True in boolean context, so '-and' returns the last value, 3.
📝 Syntax
expert2:00remaining
Which option causes a syntax error in PowerShell comparison?
Which of these lines will cause a syntax error when run in PowerShell?
Attempts:
2 left
💡 Hint
PowerShell uses '-eq' for equality, not '='.
✗ Incorrect
Option C uses '=' which is an assignment operator, not a comparison operator, causing a syntax error in this context.