Recall & Review
beginner
What does the range operator (..) do in PowerShell?
It creates an array of numbers from a start value to an end value, including both.
Click to reveal answer
beginner
How do you create a sequence of numbers from 1 to 5 using the range operator?
Use
1..5 which produces the array 1, 2, 3, 4, 5.Click to reveal answer
intermediate
What happens if the start number is greater than the end number in a range expression like
5..1?PowerShell creates a descending array:
5, 4, 3, 2, 1.Click to reveal answer
beginner
Can the range operator be used with variables? Give an example.
Yes. For example,
$start=3; $end=7; $start..$end creates 3, 4, 5, 6, 7.Click to reveal answer
beginner
Is the range operator inclusive or exclusive of the end values?
It is inclusive, meaning both the start and end numbers are included in the output array.
Click to reveal answer
What does the PowerShell expression
2..6 produce?✗ Incorrect
The range operator creates an array including both start and end numbers, so 2 to 6 includes 2,3,4,5,6.
What is the output of
10..7 in PowerShell?✗ Incorrect
When the start is greater than the end, the range operator counts down, producing 10,9,8,7.
Which of these is a valid way to use the range operator with variables?
✗ Incorrect
PowerShell supports using variables directly with the range operator like $a..$b.
If you want numbers from 1 to 10, which is the correct PowerShell syntax?
✗ Incorrect
The range operator is written as two dots between numbers: 1..10.
Does the range operator include the last number in the sequence?
✗ Incorrect
The range operator always includes both the start and end numbers in the output.
Explain how the range operator (..) works in PowerShell and give an example.
Think about how you count numbers from one to another.
You got /3 concepts.
What happens if the first number is bigger than the second in a range expression? Describe the output.
Consider counting backwards.
You got /3 concepts.