0
0
PowerShellscripting~10 mins

Measure-Object for statistics 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 calculate the sum of numbers in the array.

PowerShell
$numbers = 1, 2, 3, 4, 5
$result = $numbers | Measure-Object -[1]
$result.Sum
Drag options to blanks, or click blank then click option'
ACount
BMaximum
CAverage
DSum
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Count' instead of '-Sum' returns the number of elements, not their total.
Using '-Average' returns the mean, not the sum.
2fill in blank
medium

Complete the code to calculate the average of numbers in the array.

PowerShell
$values = 10, 20, 30, 40
$avg = $values | Measure-Object -[1]
$avg.Average
Drag options to blanks, or click blank then click option'
AMaximum
BAverage
CSum
DMinimum
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Sum' returns the total, not the average.
Using '-Maximum' returns the largest number, not the average.
3fill in blank
hard

Fix the error in the code to get the maximum value from the list.

PowerShell
$list = 5, 15, 25, 35
$maxValue = $list | Measure-Object -[1]
$maxValue.Maximum
Drag options to blanks, or click blank then click option'
AMaximum
BMax
CSum
DMin
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Max' causes an error because it's not a valid parameter.
Using '-Min' returns the smallest number, not the maximum.
4fill in blank
hard

Fill both blanks to calculate the minimum and count of numbers in the array.

PowerShell
$data = 3, 6, 9, 12
$result = $data | Measure-Object -[1] -[2]
$result.Minimum; $result.Count
Drag options to blanks, or click blank then click option'
AMinimum
BSum
CCount
DAverage
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Sum' instead of '-Count' returns total, not count.
Using '-Average' instead of '-Minimum' returns mean, not smallest number.
5fill in blank
hard

Fill all three blanks to calculate sum, average, and count of numbers.

PowerShell
$nums = 2, 4, 6, 8
$stats = $nums | Measure-Object -[1] -[2] -[3]
$stats.Sum; $stats.Average; $stats.Count
Drag options to blanks, or click blank then click option'
AMaximum
BAverage
CCount
DSum
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up parameters like using '-Maximum' instead of '-Sum'.
Omitting one of the parameters causes missing statistics.