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

3/3

Page

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

Tuples can't be made keys of a dictionary.

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>> a=(0,1,2,3,4)
>>> b=slice(0,2)
>>> a[b]

Select an option to see the answer and solution.

Is the following Python code valid?
>>> a,b,c=1,2,3
>>> a,b,c

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>t = (1, 2)
>>>2 * t

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>> a,b=6,7
>>> a,b=b,a
>>> a,b

Select an option to see the answer and solution.

If a=(1,2,3,4), a[1:-1] is . . . . . . . .

Select an option to see the answer and solution.

What will be the output of the following Python code?
numberGames = {}
numberGames[(1,2,4)] = 8
numberGames[(4,2,1)] = 10
numberGames[(1,2)] = 12
sum = 0
for k in numberGames:
    sum += numberGames[k]
print(len(numberGames) + sum)

Select an option to see the answer and solution.

What will be the output of the following Python code?
d = {"john":40, "peter":45}
d["john"]

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>> a=(2,3,4)
>>> sum(a,3)

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
a = ('check',)
n = 2
for i in range(int(n)):
    a = (a,)
    print(a)

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>my_tuple = (1, 2, 3, 4)
>>>my_tuple.append( (5, 6, 7) )
>>>print len(my_tuple)

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>>t = (1, 2, 4, 3, 8, 9)
>>>[t[i] for i in range(0, len(t), 2)]

Select an option to see the answer and solution.

Is the following Python code valid?
>>> a,b=1,2,3

Select an option to see the answer and solution.

Is the following Python code valid?
>>> a=2,3,4,5
>>> a

Select an option to see the answer and solution.

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

Select an option to see the answer and solution.

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

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:3]

Select an option to see the answer and solution.

What will be the output of the following Python code?
>>> a=(1,2)
>>> b=(3,4)
>>> c=a+b
>>> c

Select an option to see the answer and solution.