0
0
PowerShellscripting~20 mins

Why operators perform comparisons and logic in PowerShell - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PowerShell Logic Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the output of this PowerShell comparison?
Consider this PowerShell command:
$result = 5 -gt 3
Write-Output $result

What will be the output?
PowerShell
$result = 5 -gt 3
Write-Output $result
ATrue
BFalse
C5
D3
Attempts:
2 left
💡 Hint
The '-gt' operator checks if the left value is greater than the right value.
💻 Command Output
intermediate
2:00remaining
What does this logical operation output?
Look at this PowerShell code:
$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
ATrue
B0
C1
DFalse
Attempts:
2 left
💡 Hint
The '-and' operator returns True only if both sides are True.
💻 Command Output
advanced
2:00remaining
What is the output of this combined comparison and logic?
Analyze this PowerShell snippet:
$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
ATrue
BFalse
C10
D20
Attempts:
2 left
💡 Hint
The '-or' operator returns True if at least one side is True.
💻 Command Output
advanced
2:00remaining
What does this PowerShell code output?
Look at this code:
$result = 5 -and 3
Write-Output $result

What happens when you run it?
PowerShell
$result = 5 -and 3
Write-Output $result
AFalse
B3
CTrue
D5
Attempts:
2 left
💡 Hint
In PowerShell, '-and' returns the last evaluated value if both are true-like.
📝 Syntax
expert
2:00remaining
Which option causes a syntax error in PowerShell comparison?
Which of these lines will cause a syntax error when run in PowerShell?
A$result = 10 -eq 10
B$result = 10 -ne 5
C$result = 10 = 10
D$result = 10 -lt 20
Attempts:
2 left
💡 Hint
PowerShell uses '-eq' for equality, not '='.