12
Question Question 12
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)
(i), (iii)
Reason — Both will yield (5, 3, 1, 9). We can use indexes of tuple elements to create tuple slices as per following format : seq = T[start:stop]