KnowledgeBoat Logo

Computer Science

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()

Python Tuples

7 Likes

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'.

Answered By

2 Likes


Related Questions