0
0
PowerShellscripting~10 mins

Assignment operators 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 add 5 to the variable $count using an assignment operator.

PowerShell
$count [1] 5
Drag options to blanks, or click blank then click option'
A*=
B-=
C+=
D/=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' will subtract instead of add.
Using '*' or '/' will multiply or divide instead of adding.
2fill in blank
medium

Complete 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'
A+=
B-=
C/=
D*=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will add instead of multiply.
Using '-=' or '/=' will subtract or divide instead of multiply.
3fill in blank
hard

Fix 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'
A-=
B+=
C*=
D/=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' will add instead of subtract.
Using '*=' or '/=' will multiply or divide instead of subtract.
4fill in blank
hard

Fill 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'
A/=
B*=
C+=
D-=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+=' or '-=' instead of '/=' or '*=' will perform wrong operations.
Mixing up the order of operators.
5fill in blank
hard

Fill 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'
A+=
B-=
C*=
D/=
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong operators for the intended operations.
Mixing up the order of operations.