Computer Science
What will be the output of the following Python code?
tp = (5)
tp1 = tp * 2
print(len(tp1))
- 0
- 2
- 1
- Error
Python Tuples
17 Likes
Answer
Error
Reason — tp is not a tuple and holds an integer value hence object of type 'int' has no len()
Answered By
1 Like
Related Questions
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
What will be the output of the following Python code?
tp = (5,) tp1 = tp * 2 print(len(tp1))
- 0
- 2
- 1
- Error
Given tp = (5,3,1,9,0). Which of the following two statements will give the same output?
(i) print( tp[:-1] )
(ii) print( tp[0:5] )
(iii) print( tp[0:4] )
(iv) print( tp[-4:] )- (i), (ii)
- (ii), (iv)
- (i), (iv)
- (i), (iii)