CBSE Class 11 Computer Science
Question 44 of 98
Python Programming Fundamentals — Question 6
Back to all questions8 5
x = 3
y = x + 2xis initialized to 3.yis set tox + 2, which means y = 3 + 2 = 5.
x += yThe += operator adds the value of y to x and assigns the result back to x.
- Current values are:
- x = 3
- y = 5
- Calculation: x + y = 3 + 5 = 8
- Updating
x: x += 5 means x = x + 5 - So, x = 3 + 5 = 8.
print(x, y)The final values of the variables are:
- x = 8
- y = 5
Hence, the output of the program is:
8 5