CBSE Class 11 Computer Science Question 65 of 114

Tuples — Question 2

Back to all questions
2
Question

Question 1(b)

Find the output generated by following code fragments :

(a, b, c) = (1, 2, 3)
Answer
Output
a = 1
b = 2
c = 3
Explanation

When we put tuples on both sides of an assignment operator, a tuple unpacking operation takes place. The values on the right are assigned to the variables on the left according to their relative position in each tuple. As you can see in the above example, a will be 1, b will be 2, and c will be 3.