Bird
0
0

Which of the following PowerShell commands correctly creates a range of integers from 2 to 6?

easy📝 Syntax Q3 of 15
PowerShell - Operators
Which of the following PowerShell commands correctly creates a range of integers from 2 to 6?
A2..6
B6..2
C2-6
DRange(2,6)
Step-by-Step Solution
Solution:
  1. Step 1: Identify the correct range syntax

    PowerShell uses the .. operator to create ranges, e.g., start..end.
  2. Step 2: Evaluate options

    2..6 uses 2..6, which is correct. 6..2 is reversed and creates a descending range. 2-6 is invalid syntax. Range(2,6) is not a PowerShell range syntax.
  3. Final Answer:

    2..6 -> Option A
  4. Quick Check:

    Check for correct operator and ascending order [OK]
Quick Trick: Use '..' operator for ranges, e.g., 2..6 [OK]
Common Mistakes:
  • Using a dash (-) instead of two dots (..)
  • Reversing the range start and end
  • Using non-PowerShell syntax like Range()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes