MCQ on Python Tuple – 2

Q1) Which of the following statements will create an empty tuple?

a) P = ( )
b) Q = tuple( )
c) Both of the above
d) None of the above

View Answer Answer:- c) Both of the above

Q2) Find the output of the given Python program?

x = {"Robert":25, "Elon":29}
y = x["Elon"]
print(y)

a) Robert
b) Elon
c) 25
d) 29

View Answer Answer:- d) 29

Q3) What will be the output of the 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 Answer:- d) Error

Q4) Is the following Python code valid?

>>> a=(5,4,3,2,1)
>>> del a

a) Yes, the entire tuple is deleted
b) Yes, the first element in the tuple is deleted
c) No because the tuple is immutable
d) No, the invalid syntax for the del method

View Answer Answer:- a) Yes, the entire tuple is deleted

Q5) What is the output of the given below program?

t = (5,4,3,2,1)
x = del(t[3])
print(x)

a) (5, 4, 2, 1)
b) (5, 4, 3, 1)
c) (5, 4)
d) Error

View Answer Answer:- d) Error

Q6) Find the output of the given Python program?

t = (3, 5)
x = 3 * t
print(x)

a) (3, 5)
b) (3, 3, 5)
c) (3, 3, 3, 5, 5, 5)
d) (3, 5, 3, 5, 3, 5)

View Answer Answer:- d) (3, 5, 3, 5, 3, 5)

Q7) Find the output of the given Python program?

t = (3, 5)*3
print(t)

a) (3, 5)
b) (3, 3, 5)
c) (3, 3, 3, 5, 5, 5)
d) (3, 5, 3, 5, 3, 5)

View Answer Answer:- d) (3, 5, 3, 5, 3, 5)

Q8) Which mathematical operator is used to replicate a tuple?

a) Modulus
b) Multiplication
c) Addition
d) Exponent

View Answer Answer:- b) Multiplication

Q9) What is the output of the given below program?

t = (5,4,3,2,1)
x = t[2:4]
print(x)

a) (4, 2)
b) (3, 2)
c) (5, 4, 1)
d) (4, 3, 2)

View Answer Answer:- b) (3, 2)

Q10) What is the output of the given below program?

t = (5, 4, 3, 2, 1)
x = t[2:-1]
print(x)

a) (4, 2)
b) (3, 2)
c) (5, 4, 1)
d) (4, 3, 2)

View Answer Answer:- b) (3, 2)

Q11) What is the output of the given below program?

t = (1,2,3,4,5)
x = slice(2,4)
print(t[x])

a) (1, 2, 3, 4, 5)
b) (1, 3, 5)
c) (3, 4)
d) Error

View Answer Answer:- c) (3, 4)

Also See:- MCQ on Tuple in Python-3

Leave a Comment

Your email address will not be published.