Bird
0
0

Which of these PowerShell expressions uses the range operator correctly to create numbers from 10 down to 6?

easy📝 Conceptual Q2 of 15
PowerShell - Operators
Which of these PowerShell expressions uses the range operator correctly to create numbers from 10 down to 6?
A10..6 | Sort-Object
B10..6
C10 - 6
D6..10
Step-by-Step Solution
Solution:
  1. Step 1: Identify how the range operator works with descending numbers

    When the left number is greater than the right, the range operator creates a descending sequence.
  2. Step 2: Check the options

    10..6 uses 10..6 which creates 10, 9, 8, 7, 6. 6..10 creates ascending 6 to 10. 10 - 6 is subtraction, not range. 10..6 | Sort-Object sorts ascending, not descending.
  3. Final Answer:

    10..6 creates a descending sequence from 10 to 6 -> Option B
  4. Quick Check:

    Descending range = left..right with left>right [OK]
Quick Trick: Range operator can create descending sequences if left>right [OK]
Common Mistakes:
  • Assuming range operator only creates ascending sequences
  • Using subtraction instead of range operator
  • Sorting ascending instead of descending

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes