Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to calculate the sum of 5 and 3 using arithmetic expansion.
Bash Scripting
result=$((5 [1] 3)) echo $result
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' will subtract instead of add.
Using '*' or '/' will multiply or divide, not add.
✗ Incorrect
The plus sign (+) inside $(( )) adds the two numbers.
2fill in blank
mediumComplete the code to multiply 7 by 4 using arithmetic expansion.
Bash Scripting
result=$((7 [1] 4)) echo $result
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' or '-' will add or subtract instead of multiply.
Using '/' will divide instead of multiply.
✗ Incorrect
The asterisk (*) inside $(( )) multiplies the two numbers.
3fill in blank
hardFix the error in the code to correctly subtract 2 from 10 using arithmetic expansion.
Bash Scripting
result=$((10 [1] 2)) echo $result
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 minus sign (-) inside $(( )) subtracts the second number from the first.
4fill in blank
hardFill both blanks to calculate (17 % 5) - 2 using arithmetic expansion.
Bash Scripting
result=$((17 [1] 5 [2] 2)) echo $result
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '+' instead of '-' changes the result.
Using '*' instead of '%' does not give remainder.
✗ Incorrect
The modulus operator (%) gives the remainder. The minus sign (-) is used to subtract 2 from the remainder.
5fill in blank
hardFill all three blanks to create a dictionary-like output with keys as numbers and values as their squares, but only for numbers greater than 3.
Bash Scripting
declare -A squares for num in {1..5}; do if (( num [1] 3 )); then squares[[2]]=$((num [3] num)) fi done for key in "${!squares[@]}"; do echo "$key: ${squares[$key]}" done
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>' changes the filter condition.
Using wrong variable names causes errors.
Using '+' instead of '*' does not square the number.
✗ Incorrect
The condition 'num > 3' filters numbers greater than 3. The key is 'num' and the value is 'num * num' (square).