placeholder image to represent content

PowerShell Comparison and Logical Operators

Quiz by Aaron Curtis

Our brand new solo games combine with your quiz, on the same screen

Correct quiz answers unlock more play!

New Quizalize solo game modes
11 questions
Show answers
  • Q1
    Write an expression testing whether the variable $name is equal to 'Sale'
    $name -eq 'Sale'
    $name -is 'Sale'
    $name = 'Sale'
    $name == 'Sale'
    30s
  • Q2
    Write an expression testing whether 9 is less than 8
    9 < 8
    less(9,8)
    9 -lt 8
    8 < 9
    30s
  • Q3
    Write an expression testing whether 7 is greater than 6
    isGreater(7,6)
    7 -gt 6
    9 -more 6
    7 > 6
    30s
  • Q4
    Write an expression testing whether 10 is less than or equal to 20
    10 -le 20
    10 -lessThanEqual 20
    lessEqual(10,20)
    10 <= 20
    30s
  • Q5
    Write an expression testing whether the variable $abc contains the string 'love'
    $abc -like '*love*'
    '*love*' -like $abc
    'love' -like $abc
    $abc -like 'love'
    30s
  • Q6
    Write an expression testing whether the variable $def contains the string 'hash'. The test should be case sensitive.
    $def -like '%hash%'
    $def -clike '*hash*'
    $def -case '*hash*'
    $def -like '*hash*'
    30s
  • Q7
    The variable $abc contains the string 'I love hash tables'. Write an expression to display the contents of $abc but replacing 'tables' with 'browns'
    $abc -rep 'tables', 'browns'
    $abc >> $abc - 'tables' + 'browns'
    $abc -replace 'tables', 'browns'
    $abc | 'tables', 'browns'
    30s
  • Q8
    Write an expression testing whether $num is NOT equal to 8.
    $num -ne 8
    $num <> 8
    $num != 8
    !($num = 8)
    30s
  • Q9
    Write an expression testing whether $a is equal to 3 AND $b is less than or equal to 5
    ($a -eq 3) -and ($b -le 5)
    ($a -eq 3) AND ($b -le 5)
    ($a -eq 3) & ($b -le 5)
    ($a -eq 3) && ($b -le 5)
    30s
  • Q10
    Write an expression testing whether $a contains the string 'windows' OR $b is less than 9
    ($a -like '*windows*') ^ ($b -lt 9)
    ($a -like '*windows*') OR ($b -lt 9)
    ($a -like '*windows*') -or ($b -lt 9)
    ($a -like '*windows*') || ($b -lt 9)
    30s
  • Q11
    Write and expression testing whether $a equal 2 or $b equals 8. Only one of these two statements may be true.
    ($a -eq 2) -xor ($b -eq 8)
    ($a -eq 2) <-> ($b -eq 8)
    ($a -eq 2) XOR ($b -eq 8)
    ($a -eq 2) <>OR ($b -eq 8)
    30s

Teachers give this quiz to your class