Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete 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'
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.
✗ Incorrect
The '-Sum' parameter tells Measure-Object to calculate the sum of the input numbers.
2fill in blank
mediumComplete 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-Sum' returns the total, not the average.
Using '-Maximum' returns the largest number, not the average.
✗ Incorrect
The '-Average' parameter calculates the mean value of the input numbers.
3fill in blank
hardFix 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'
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.
✗ Incorrect
The correct parameter is '-Maximum' to get the largest number.
4fill in blank
hardFill 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'
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.
✗ Incorrect
Use '-Minimum' to get the smallest number and '-Count' to get the number of elements.
5fill in blank
hardFill 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'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up parameters like using '-Maximum' instead of '-Sum'.
Omitting one of the parameters causes missing statistics.
✗ Incorrect
Use '-Sum' for total, '-Average' for mean, and '-Count' for number of elements.