CBSE Class 11 Computer Science Question 76 of 98

Python Programming Fundamentals — Question 38

Back to all questions
38
Question

Question 25

Give the output.

x, y = 20, 60
y, x, y = x, y - 10, x + 10
print (x, y)
Answer
Output
50 30
Explanation
  1. x, y = 20, 60 ⇒ assigns an initial value of 20 to x and 60 to y.
  2. y, x, y = x, y - 10, x + 10 ⇒ y, x, y = 20, 60 - 10, 20 + 10 ⇒ y, x, y = 20, 50, 30 First RHS value 20 is assigned to first LHS variable y. After that second RHS value 50 is assigned to second LHS variable x. Finally third RHS value 30 is assigned to third LHS variable which is again y. After this assignment, x becomes 50 and y becomes 30.
  3. print (x, y) ⇒ prints the value of x and y as 50 and 30 respectively.