0
0
PowerShellscripting~10 mins

Arithmetic 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 two numbers and store the result in $sum.

PowerShell
$a = 5
$b = 3
$sum = $a [1] $b
Write-Output $sum
Drag options to blanks, or click blank then click option'
A-
B*
C+
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' which subtracts instead of adds.
Using '*' which multiplies instead of adds.
2fill in blank
medium

Complete the code to multiply two numbers and display the product.

PowerShell
$x = 7
$y = 4
$product = $x [1] $y
Write-Output $product
Drag options to blanks, or click blank then click option'
A*
B+
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' which adds instead of multiplies.
Using '/' which divides instead of multiplies.
3fill in blank
hard

Fix the error in the code to correctly divide two numbers and show the result.

PowerShell
$num1 = 20
$num2 = 5
$result = $num1 [1] $num2
Write-Output $result
Drag options to blanks, or click blank then click option'
A+
B/
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '*' which multiplies instead of divides.
Using '+' which adds instead of divides.
4fill in blank
hard

Fill in the blank to calculate the remainder when 17 is divided by 3.

PowerShell
$a = 17
$b = 3
$remainder = $a [1] $b
Write-Output $remainder
Drag options to blanks, or click blank then click option'
A%
B+
C-
D*
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' which subtracts instead of finding remainder.
Using '*' which multiplies instead of finding remainder.
5fill in blank
hard

Fill both blanks to calculate the expression: (8 + 2) * 5.

PowerShell
$a = 8
$b = 2
$c = 5
$result = ($a [1] $b) [2] $c
Write-Output $result
Drag options to blanks, or click blank then click option'
A+
B*
C-
D/
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' for addition.
Using '/' instead of '*' for multiplication.