0
0
PowerShellscripting~10 mins

Range operator (..) in PowerShell - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a range of numbers from 1 to 5.

PowerShell
$numbers = 1 [1] 5
$numbers
Drag options to blanks, or click blank then click option'
A-
B..
C:
D...
Attempts:
3 left
💡 Hint
Common Mistakes
Using a single dash (-) instead of the range operator.
Using three dots (...) which is not valid in PowerShell for ranges.
2fill in blank
medium

Complete the code to create a descending range from 5 down to 1.

PowerShell
$numbers = 5 [1] 1
$numbers
Drag options to blanks, or click blank then click option'
A-
B...
C:
D..
Attempts:
3 left
💡 Hint
Common Mistakes
Trying to use a dash (-) to create a range.
Using three dots (...) which is invalid.
3fill in blank
hard

Fix the error in the code to generate numbers from 1 to 10.

PowerShell
$nums = 1 [1] 10
$nums
Drag options to blanks, or click blank then click option'
A..
B-
C:
D...
Attempts:
3 left
💡 Hint
Common Mistakes
Using a dash (-) which subtracts instead of creating a range.
Using three dots (...) which is not valid.
4fill in blank
hard

Fill both blanks to create a range from 3 to 7 and then select numbers greater than 4.

PowerShell
$range = [1] [2] 7
$filtered = $range | Where-Object { $_ -gt 4 }
$filtered
Drag options to blanks, or click blank then click option'
A3
B..
C-
D5
Attempts:
3 left
💡 Hint
Common Mistakes
Using a dash (-) instead of the range operator.
Using 5 as the start number instead of 3.
5fill in blank
hard

Fill all three blanks to create a range from 2 to 6 and filter numbers less than 5.

PowerShell
$nums = [1] [2] 6
$filtered = $nums | Where-Object { $_ [3] 5 }
$filtered
Drag options to blanks, or click blank then click option'
A2
B..
C-lt
D-gt
Attempts:
3 left
💡 Hint
Common Mistakes
Using -gt instead of -lt for filtering less than.
Using wrong start number or operator.