Arithmetic operations in Sass are calculations like addition (+), subtraction (-), multiplication (*), division (/), and modulo (%) used to compute values for styles.
Click to reveal answer
beginner
How do you add two numbers in Sass?
You use the plus sign (+). For example: $total: 10 + 5; sets $total to 15.
Click to reveal answer
beginner
What happens if you divide two numbers in Sass?
Sass divides the numbers and returns the result. For example, $result: 20 / 4; sets $result to 5.
Click to reveal answer
intermediate
Can you use arithmetic operations with units in Sass? Give an example.
Yes, you can. For example, $width: 100px / 2; results in 50px. Sass keeps the unit when dividing or multiplying.
Click to reveal answer
intermediate
What is the modulo (%) operation in Sass?
Modulo (%) gives the remainder of division. For example, 7 % 3 equals 1 because 3 goes into 7 twice with 1 left over.
Click to reveal answer
Which symbol is used for multiplication in Sass arithmetic?
A*
B-
C+
D/
✗ Incorrect
The asterisk (*) is used for multiplication in Sass.
What will $result: 15 - 5; set $result to?
A5
B20
C10
D0
✗ Incorrect
15 minus 5 equals 10.
If $size: 50px / 5;, what is the value of $size?
A10px
B5px
C250px
D10
✗ Incorrect
Dividing 50px by 5 results in 10px, Sass keeps the unit.
What does the modulo operator (%) return?
AThe quotient of division
BThe sum of two numbers
CThe product of two numbers
DThe remainder of division
✗ Incorrect
Modulo (%) returns the remainder after division.
Which of these is NOT a valid arithmetic operator in Sass?
A+
B&
C*
D/
✗ Incorrect
The ampersand (&) is not an arithmetic operator in Sass.
Explain how you can use arithmetic operations in Sass to calculate widths with units.
Think about how Sass handles units when you multiply or divide numbers.
You got /6 concepts.
Describe the modulo operation and give a simple example of when it might be useful in Sass.
Modulo helps find leftovers after dividing numbers.
You got /4 concepts.
Practice
(1/5)
1. What does the Sass expression 10px + 5px produce?
easy
A. Syntax error
B. 105px
C. 15px
D. 5px
Solution
Step 1: Understand addition of units in Sass
Sass adds numbers with the same units by adding their numeric values and keeping the unit.
Step 2: Calculate the sum of 10px and 5px
10 + 5 equals 15, so the result is 15px.
Final Answer:
15px -> Option C
Quick Check:
10px + 5px = 15px [OK]
Hint: Add numbers only if units match exactly [OK]
Common Mistakes:
Concatenating numbers as strings (getting 105px)
Ignoring units and returning just number
Thinking addition causes syntax error
2. Which of the following is the correct Sass syntax to multiply 8px by 3?
easy
A. 8px * 3
B. 8px x 3
C. multiply(8px, 3)
D. 8px ** 3
Solution
Step 1: Identify the multiplication operator in Sass
Sass uses the asterisk (*) symbol for multiplication.
Step 2: Check each option for correct syntax
8px * 3 uses * correctly; others use invalid syntax.
Final Answer:
8px * 3 -> Option A
Quick Check:
Multiplication uses * operator [OK]
Hint: Use * for multiplication, not x or other symbols [OK]
Common Mistakes:
Using 'x' instead of '*' for multiplication
Trying function calls like multiply() which Sass doesn't have