Page-7 |
|||
Tuple |
|||
91)Which one of the following will create a tuple? | |||
T=(3)*3 | T=(3,)*3 | ||
T[3]=(1, 2, 3) | None of these | ||
Answer : | |||
|
|||
92)Which one of the following is correct? | |||
List is immutable but tuple is mutable | Both list and tuple are immutable | ||
Tuple is immutable but list is mutable | Both tuple and list are mutable | ||
Answer : | |||
|
|||
93)Which one of the following is correct? | |||
Tuple can contain only string | Tuple can contain only integer | ||
Tuple can contain only string and integer | Tuple can contain different types of elements | ||
Answer : | |||
|
|||
94)Which one of the following will create a tuple with single element? | |||
T=(4,) | T=(5) | ||
T=([5]) | T=tuple(5) | ||
Answer : | |||
|
|||
95)If T=() then what will be the output of print(len(T*2))? | |||
Error | 1 | ||
0 | 2 | ||
Answer : | |||
|
|||
96)Which one of the following is a correct declaration of a tuple? | |||
T=['Karan', 'Kishor', 'Kavita', 'Krishna'] | T=(['Karan', 'Kishor', 'Kavita', 'Krishna']) | ||
T=('Karan', 'Kishor', 'Kavita', 'Krishna') | T=(['Karan', 'Kishor', 'Kavita', 'Krishna') | ||
Answer : | |||
|
|||
97)If T=(2, 4, 6) then what is the output of print(T*3)? | |||
(6, 12, 18) | (2, 4, 6, 2, 4, 6, 2, 4, 6) | ||
(2, 2, 2, 4, 4, 4, 6, 6, 6) | Error | ||
Answer : | |||
|
|||
|
|||
98)What will be the output of the following code?
T=(1, 2, 3, 4, 5) T.pop() print(T) |
|||
(1, 2, 3, 4) | (2, 3, 4, 5) | ||
(1, 2, 3, 4, 5) | Error | ||
Answer : | |||
|
|||
99)If T=(2, 3, 4) then which one of the following will raise an error? | |||
T.sort() | sorted(T) | ||
max(T) | sum(T) | ||
Answer : | |||
|
|||
100)What is the output of the following code?
T=(5) T1=T*2 print(len(T1)) |
|||
10 | 0 | ||
1 | Error | ||
Answer : | |||
|
|||
101)Predict the output of the following code.
T=(3,) T1=T*4 print(len(T1)) |
|||
0 | 3 | ||
4 | Error | ||
Answer : | |||
|
|||
102)If T=(1, 2, 3, 4, 5, 6,7) then what will be the output of print(t[5:-1]) | |||
Error | (6,) | ||
( ) | (6, 7) | ||
Answer : | |||
|
|||
103)If T=(1, 2, 3, 4, 5, 6,7) then what will be the output of print(t[:-1]) | |||
(1, 2, 3, 4, 5, 6) | (1, 2, 3, 4, 5, 6, 7) | ||
(7,) | ( ) | ||
Answer : | |||
|
|||
104)If T=(1, 2, 3, 4, 5, 6,7) then what will be the output of print(t[::-1]) | |||
(1, 2, 3, 4, 5, 6, 7) | (7, 6, 5, 4, 3, 2, 1) | ||
( ) | (7,) | ||
Answer : | |||
|
|||
105)If T=(1, 2, 3, 4, 5, 6,7) then which two of the following will give the same output.
i) print(T[0:7]) ii) print(T[0:6]) iii) print(T[:-1]) iv) print(T[0:-6]) |
|||
(i) and (ii) | (ii) and (iii) | ||
(iii) and (iv) | (i) and (iii) | ||
Answer : | |||
|