ADHARSH VIDHYALAYA PUBLIC SCHOOL
Sub-Topic : TUPLE MANIPULATION
Name of Student : ________________________________________
Q1. Which of the following creates a tuple?
A. tuple1=("a","b") B. tuple1[2]=("a","b") C. tuple1=(5)*2 D. None of the above
Q2. Choose the correct option with respect to Python.
A. Both tuples and lists are immutable.
B. Tuples are immutable while lists are mutable.
C. Both tuples and lists are mutable.
D. Tuples are mutable while lists are immutable.
Q3. Choose the correct option.
A. In Python, a tuple can contain only integers as its elements.
B. In Python, a tuple can contain only strings as its elements.
C. In Python, a tuple can contain both integers and strings as its elements.
D. In Python, a tuple can contain either string or integer but not both at a time.
Q4. What will be the output of below Python code?
tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)
Q5. What will be the output of below Python code?
tuple1=(2,4,3)
tuple3=tuple1*2
print(tuple3)
Q6. . What will be the output of below Python code?
tupl=("annie","hena","sid")
print(tupl[-3:0])
Q7. Which of the following options will not result in an error when performed
on tuples in Python where tupl=(5,2,7,0,3)?
A. tupl[1]=2 B. tupl.append(2) C. tupl1=tupl+tupl D. tupl.sort()
Q8. What will be the output of below Python code?
tupl=()
tupl1=tupl*2
print(len(tupl1))
Q9. What will be the output of below Python code?
tupl=([2,3],"abc",0,9)
tupl[0][1]=1
print(tupl)
Q10 Which of the following two Python codes will give same output?
.
(i) print(tupl[:-1]) (ii) print(tupl[0:5])
(iii) print(tupl[0:4]) (iv) print(tupl[-4:])
If tupl=(5,3,1,9,0)
A. i, ii B. ii, iv C. i, iv D. i, iii
Q11 Which of the following is a Python tuple?
.
a) [1, 2, 3] b) (1, 2, 3) c) {1, 2, 3} d) {}
Q12 Suppose t = (1, 2, 4, 3), which of the following is incorrect?
. a) print(t[3]) b) t[3] = 45 c) print(max(t)) d) print(len(t))
Q13 What will be the output of the following Python code?
.
1.>>>t=(1,2,4,3)
2.>>>t[1:3]
a) (1, 2) b) (1, 2, 4) c) (2, 4) d) (2, 4, 3)
Q14 What will be the output of the following Python code?
.
1.>>>t=(1,2,4,3)
2.>>>t[1:-1]
a) (1, 2) b) (1, 2, 4) c) (2, 4) d) (2, 4, 3)
Q15 What will be the output of the following Python code?
.
1.>>>t = (1, 2, 4, 3, 8, 9)
2. >>>[t[i] for i in range(0, len(t), 2)]
Q16 What will be the output of the following Python code?
.
1.d = {"john":40, "peter":45}
2. d["john"]
Q17 What will be the output of the following Python code?
.
1.>>>t = (1, 2)
2. >>>2 * t
Q18 What will be the output of the following Python code?
.
1.>>>t1 = (1, 2, 4, 3)
2.>>>t2 = (1, 2, 3, 4)
3. >>>t1 < t2
Q19 What will be the output of the following Python code?
.
>>>my_tuple = (1, 2, 3, 4)
1.>>>my_tuple.append( (5, 6, 7) )
2. >>>print len(my_tuple)