CBSE Class 11 Computer Science Question 31 of 114

Tuples — Question 8

Back to all questions
8
Question

Question 8

Which of the following options will not result in an error when performed on types in Python where tp = (5,2,7,0,3) ?

  1. tp[1] = 2
  2. tp.append(2)
  3. tp1=tp+tp
  4. tp.sum()
Answer

tp1=tp+tp

Reason — The "+" operator concatenates two tuples and creates a new tuple. First option will throw an error since tuples are immutable, item assignment not supported in tuples. Second and Fourth option will also throw an error since tuple object has no attribute 'append' and 'sum'.