Python Tuple MCQ

This section focuses on the "Tuple" in Python. These Multiple Choice Questions (mcq) should be practiced to improve the Python skills required for various interviews (campus interview, walk-in interview, company interview), placement, entrance exam and other competitive examinations.

1. 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

View Answer


2. 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.

View Answer


3. 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.

View Answer


4. What will be the output of below Python code?.

tuple1=(5,1,7,6,2)
tuple1.pop(2)
print(tuple1)

A. (5,1,6,2)
B. (5,1,7,6)
C. (5,1,7,6,2)
D. Error

View Answer


5. What will be the output of below Python code?.

tuple1=(2,4,3)
tuple3=tuple1*2
print(tuple3)

A. (4,8,6)
B. (2,4,3,2,4,3)
C. (2,2,4,4,3,3)
D. Error

View Answer


6. What will be the output of below Python code?.

tupl=("annie","hena","sid")
print(tupl[-3:0])

A. ("annie")
B. ()
C. None
D. Error as slicing is not possible in tuple.

View Answer


7. 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()

View Answer


8. What will be the output of below Python code?.

tupl=()
tupl1=tupl*2
print(len(tupl1))

A. 0
B. 2
C. 1
D. Error as tuple object has no attribute to len

View Answer


9. What will be the output of below Python code?.

tupl=([2,3],"abc",0,9)
tupl[0][1]=1
print(tupl)

A. ([2,3],"abc",0,9)
B. ([1,3],"abc",0,9)
C. ([2,1],"abc",0,9)
D. Error

View Answer


10. 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

View Answer






Also check :


Discussion


* You must be logged in to add comment.