Advertisements
Advertisements
प्रश्न
What will be the output of the following code?
tuple1 = (1, 2, 3)
tuple2 = tuple1
tuple1 += (4,)
print(tuple1 == tuple2)विकल्प
True
False
tuple1
Error
MCQ
Advertisements
उत्तर
False
Explanation:
-
Initially, both
tuple1andtuple2are(1, 2, 3). -
Tuples are immutable, so when we do
tuple1 += (4,), it creates a new tuple(1, 2, 3, 4)and assigns it totuple1. -
Now,
tuple1is(1, 2, 3, 4), buttuple2is still(1, 2, 3). -
Comparison:
(1, 2, 3, 4)is not equal to(1, 2, 3).- So, the result will be
False.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
