Compound Assignment Operators - AP Computer Science A
Card 1 of 30
What does 'x += y' do to x?
What does 'x += y' do to x?
Tap to reveal answer
Increases x by y. Equivalent to x = x + y.
Increases x by y. Equivalent to x = x + y.
← Didn't Know|Knew It →
Identify the compound assignment operator in 'x += 5'.
Identify the compound assignment operator in 'x += 5'.
Tap to reveal answer
+=. The += operator is clearly visible in the expression.
+=. The += operator is clearly visible in the expression.
← Didn't Know|Knew It →
What does the operator '+=' do?
What does the operator '+=' do?
Tap to reveal answer
Adds right operand to left and assigns the result. Equivalent to x = x + (right operand).
Adds right operand to left and assigns the result. Equivalent to x = x + (right operand).
← Didn't Know|Knew It →
Which compound assignment operator multiplies and assigns?
Which compound assignment operator multiplies and assigns?
Tap to reveal answer
=. Combines multiplication () with assignment (=).
=. Combines multiplication () with assignment (=).
← Didn't Know|Knew It →
State the operation for '-=' in code.
State the operation for '-=' in code.
Tap to reveal answer
Subtracts right operand from left and assigns. Equivalent to x = x - (right operand).
Subtracts right operand from left and assigns. Equivalent to x = x - (right operand).
← Didn't Know|Knew It →
What is the result of 'x *= 3' if x is initially 2?
What is the result of 'x *= 3' if x is initially 2?
Tap to reveal answer
- 2 × 3 = 6, then assigned back to x.
- 2 × 3 = 6, then assigned back to x.
← Didn't Know|Knew It →
What does '/=' do in terms of operation?
What does '/=' do in terms of operation?
Tap to reveal answer
Divides left operand by right and assigns. Equivalent to x = x / (right operand).
Divides left operand by right and assigns. Equivalent to x = x / (right operand).
← Didn't Know|Knew It →
Find the result: 'x %= 3' when x is 10.
Find the result: 'x %= 3' when x is 10.
Tap to reveal answer
- 10 mod 3 = 1, then assigned back to x.
- 10 mod 3 = 1, then assigned back to x.
← Didn't Know|Knew It →
What operation does 'x %= 5' perform?
What operation does 'x %= 5' perform?
Tap to reveal answer
Assigns remainder of x divided by 5. Uses modulo operator to find remainder.
Assigns remainder of x divided by 5. Uses modulo operator to find remainder.
← Didn't Know|Knew It →
What does the operator '*=' in 'x *= y' do?
What does the operator '*=' in 'x *= y' do?
Tap to reveal answer
Multiplies x by y and assigns. Equivalent to x = x * y.
Multiplies x by y and assigns. Equivalent to x = x * y.
← Didn't Know|Knew It →
Identify the compound assignment operator in 'x += 5'.
Identify the compound assignment operator in 'x += 5'.
Tap to reveal answer
+=. The += operator is clearly visible in the expression.
+=. The += operator is clearly visible in the expression.
← Didn't Know|Knew It →
What does the operator '+=' do?
What does the operator '+=' do?
Tap to reveal answer
Adds right operand to left and assigns the result. Equivalent to x = x + (right operand).
Adds right operand to left and assigns the result. Equivalent to x = x + (right operand).
← Didn't Know|Knew It →
Find the result: 'x %= 3' when x is 10.
Find the result: 'x %= 3' when x is 10.
Tap to reveal answer
- 10 mod 3 = 1, then assigned back to x.
- 10 mod 3 = 1, then assigned back to x.
← Didn't Know|Knew It →
Which compound assignment operator multiplies and assigns?
Which compound assignment operator multiplies and assigns?
Tap to reveal answer
=. Combines multiplication () with assignment (=).
=. Combines multiplication () with assignment (=).
← Didn't Know|Knew It →
State the operation for '-=' in code.
State the operation for '-=' in code.
Tap to reveal answer
Subtracts right operand from left and assigns. Equivalent to x = x - (right operand).
Subtracts right operand from left and assigns. Equivalent to x = x - (right operand).
← Didn't Know|Knew It →
What operation does 'x %= 5' perform?
What operation does 'x %= 5' perform?
Tap to reveal answer
Assigns remainder of x divided by 5. Uses modulo operator to find remainder.
Assigns remainder of x divided by 5. Uses modulo operator to find remainder.
← Didn't Know|Knew It →
What does 'x += y' do to x?
What does 'x += y' do to x?
Tap to reveal answer
Increases x by y. Equivalent to x = x + y.
Increases x by y. Equivalent to x = x + y.
← Didn't Know|Knew It →
What does the operator '*=' in 'x *= y' do?
What does the operator '*=' in 'x *= y' do?
Tap to reveal answer
Multiplies x by y and assigns. Equivalent to x = x * y.
Multiplies x by y and assigns. Equivalent to x = x * y.
← Didn't Know|Knew It →
What result does 'x %= 4' give if x is 9?
What result does 'x %= 4' give if x is 9?
Tap to reveal answer
- 9 mod 4 = 1, then assigned back to x.
- 9 mod 4 = 1, then assigned back to x.
← Didn't Know|Knew It →
What is the result of 'y /= 2' if y is 9?
What is the result of 'y /= 2' if y is 9?
Tap to reveal answer
4.5. 9 ÷ 2 = 4.5, then assigned back to y.
4.5. 9 ÷ 2 = 4.5, then assigned back to y.
← Didn't Know|Knew It →
What is the result of 'y /= 2' if y is 9?
What is the result of 'y /= 2' if y is 9?
Tap to reveal answer
4.5. 9 ÷ 2 = 4.5, then assigned back to y.
4.5. 9 ÷ 2 = 4.5, then assigned back to y.
← Didn't Know|Knew It →
Which operator is used for addition and assignment?
Which operator is used for addition and assignment?
Tap to reveal answer
+=. Combines addition (+) with assignment (=).
+=. Combines addition (+) with assignment (=).
← Didn't Know|Knew It →
What result does 'x %= 4' give if x is 9?
What result does 'x %= 4' give if x is 9?
Tap to reveal answer
- 9 mod 4 = 1, then assigned back to x.
- 9 mod 4 = 1, then assigned back to x.
← Didn't Know|Knew It →
Which operator performs division and assignment?
Which operator performs division and assignment?
Tap to reveal answer
/=. Combines division (/) with assignment (=).
/=. Combines division (/) with assignment (=).
← Didn't Know|Knew It →
What is the result after 'z *= 3' if z is 7?
What is the result after 'z *= 3' if z is 7?
Tap to reveal answer
- 7 × 3 = 21, then assigned back to z.
- 7 × 3 = 21, then assigned back to z.
← Didn't Know|Knew It →
What does 'x -= y' do to x?
What does 'x -= y' do to x?
Tap to reveal answer
Decreases x by y. Equivalent to x = x - y.
Decreases x by y. Equivalent to x = x - y.
← Didn't Know|Knew It →
What does 'x -= y' do to x?
What does 'x -= y' do to x?
Tap to reveal answer
Decreases x by y. Equivalent to x = x - y.
Decreases x by y. Equivalent to x = x - y.
← Didn't Know|Knew It →
What is the result after 'z *= 3' if z is 7?
What is the result after 'z *= 3' if z is 7?
Tap to reveal answer
- 7 × 3 = 21, then assigned back to z.
- 7 × 3 = 21, then assigned back to z.
← Didn't Know|Knew It →
What is the result of 'x *= 3' if x is initially 2?
What is the result of 'x *= 3' if x is initially 2?
Tap to reveal answer
- 2 × 3 = 6, then assigned back to x.
- 2 × 3 = 6, then assigned back to x.
← Didn't Know|Knew It →
What does '/=' do in terms of operation?
What does '/=' do in terms of operation?
Tap to reveal answer
Divides left operand by right and assigns. Equivalent to x = x / (right operand).
Divides left operand by right and assigns. Equivalent to x = x / (right operand).
← Didn't Know|Knew It →