Bird
0
0

Which of the following is the correct syntax for subtracting 2 from variable y using augmented assignment?

easy📝 Syntax Q3 of 15
Python - Operators and Expression Evaluation

Which of the following is the correct syntax for subtracting 2 from variable y using augmented assignment?

Ay =- 2
By = -2
Cy = y - 2
Dy -= 2
Step-by-Step Solution
Solution:
  1. Step 1: Understand the augmented subtraction syntax

    The operator -= subtracts a value from the variable and assigns the result back.
  2. Step 2: Check options for correct syntax

    y -= 2 uses y -= 2, which is the correct augmented assignment syntax.
  3. Final Answer:

    y -= 2 -> Option D
  4. Quick Check:

    Use '-=' to subtract and assign [OK]
Quick Trick: Use '-=' to subtract and assign in one step [OK]
Common Mistakes:
MISTAKES
  • Confusing '= -' with '-='
  • Assigning negative value instead of subtracting
  • Using full expression instead of augmented

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Python Quizzes