Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add 5 to the variable $count using an assignment operator.
PowerShell
$count [1] 5
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' will subtract instead of add.
Using '*' or '/' will multiply or divide instead of adding.
✗ Incorrect
The '+=' operator adds the value on the right to the variable on the left and assigns the result back to the variable.
2fill in blank
mediumComplete the code to multiply the variable $total by 3 using an assignment operator.
PowerShell
$total [1] 3
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will add instead of multiply.
Using '-=' or '/=' will subtract or divide instead of multiply.
✗ Incorrect
The '*=' operator multiplies the variable by the value on the right and assigns the result back to the variable.
3fill in blank
hardFix the error in the code to subtract 2 from $score using an assignment operator.
PowerShell
$score [1] 2
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will add instead of subtract.
Using '*=' or '/=' will multiply or divide instead of subtract.
✗ Incorrect
The '-=' operator subtracts the value on the right from the variable and assigns the result back to the variable.
4fill in blank
hardFill both blanks to divide $value by 4 and assign the result back to $value.
PowerShell
$value [1] 4 $value [2] 2
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' or '-=' instead of '/=' or '*=' will perform wrong operations.
Mixing up the order of operators.
✗ Incorrect
First, '/=' divides $value by 4 and assigns the result. Then '*=' multiplies $value by 2 and assigns the result.
5fill in blank
hardFill all three blanks to add 10 to $num, then subtract 3, then multiply by 2 using assignment operators.
PowerShell
$num [1] 10 $num [2] 3 $num [3] 2
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators for the intended operations.
Mixing up the order of operations.
✗ Incorrect
The '+=' adds 10, '-=' subtracts 3, and '*=' multiplies by 2, all updating $num each time.