Computer Science
What will be the output of following Python code?
tp1 = (15,11,17,16,12)
tp1.pop(12)
print(tp1)
- (15,11,16,12)
- (15,11,17,16)
- (15,11,17,16,12)
- Error
Python Tuples
6 Likes
Answer
Error
Reason — As tuples are immutable so they don't support pop operation.
Answered By
2 Likes
Related Questions
Which of the following will create a single element tuple ?
- (1,)
- (1)
- ( [1] )
- tuple([1])
What will be the output of following Python code?
tp1 = (2,4,3) tp3 = tp1*2 print(tp3)
- (4,8,6)
- (2,4,3,2,4,3)
- (2,2,4,4,3,3)
- Error
Which of the following options will not result in an error when performed on types in Python where tp = (5,2,7,0,3) ?
- tp[1] = 2
- tp.append(2)
- tp1=tp+tp
- tp.sum()
What will be the output of the following Python code ?
tp = () tp1 = tp * 2 print(len(tp1))
- 0
- 2
- 1
- Error