Vidyalelo
Python · all questions

MCQs on Python Tuples: Exam
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

60

Questions

2/3

Page

Pick an option on a question to see the right answer and solution.

What will be the output of the following code:
my_tuple = (1, 2, 3)
my_tuple[1] = 4
print(my_tuple)

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3]
del my_list[1]
print(my_list)

Select an option to see the answer and solution.

What will be the output of the following code:
my_list = [3, 1, 2]
my_list.sort()
print(my_list)

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3]
my_list.insert(1, 4)
print(my_list)

Select an option to see the answer and solution.

What is the purpose of the count() method for lists and tuples?

Select an option to see the answer and solution.

What will be the output of the following code:
my_list = [1, 2, 3]
my_list.reverse()
print(my_list)

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3, 4]
my_list.pop()
print(my_list)

Select an option to see the answer and solution.

What is the output of the following code:
my_tuple = (1, 2, 3)
print(my_tuple[1])

Select an option to see the answer and solution.

What is the output of the following code:
my_list = [1, 2, 3, 4]
my_list.remove(2)
print(my_list)

Select an option to see the answer and solution.

What will the following code output:
my_tuple = (1, 2, 3)
new_tuple = my_tuple.copy()
print(new_tuple)

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>t1 = (1, 2, 4, 3)
>>>t2 = (1, 2, 3, 4)
>>>t1 < t2

Select an option to see the answer and solution.

What is the data type of (1)?

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>t=(1,2,4,3)
>>>t[1:-1]

Select an option to see the answer and solution.

Is the following Python code valid?
>>> a=(1,2,3)
>>> b=('A','B','C')
>>> c=tuple(zip(a,b))

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>> a=("Check")*3
>>> a

Select an option to see the answer and solution.

Is the following Python code valid?
>>> a=(1,2,3,4)
>>> del a

Select an option to see the answer and solution.

Suppose t = (1, 2, 4, 3), which of the following is incorrect?

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>> a=[(2,4),(1,2),(3,9)]
>>> a.sort()
>>> a

Select an option to see the answer and solution.

What type of data is: a=[(1,1),(2,4),(3,9)]?

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>> import collections
>>> a=collections.namedtuple('a',['i','j'])
>>> obj=a(i=4,j=7)
>>> obj

Select an option to see the answer and solution.