CBSE Class 11 Computer Science Question 82 of 114

Tuples — Question 19

Back to all questions
19
Question

Question 3(c)

Carefully read the given code fragments and figure out the errors that the code may produce.

t1 = (3)  
t2 = (4, 5, 6)  
t3 = t1 + t2  
print (t3)
Answer
Output
TypeError: unsupported operand type(s) for +: 'int' and 'tuple'
Explanation

t1 holds an integer value not a tuple since comma is not added after the element where as t2 is a tuple. So here, we are trying to use + operator with an int and tuple operand which results in this error.