Tuples Python Questions: Tuples MCQs in Python Language

Tuples Python Questions. Multiple Choice Questions on Tuples in Python Language.

 

Tuples Python Questions

 

 

What will be the output of the following Python code ??

>>> a,b=6,7
>>> a,b=b,a
>>> a,b

a) (6,7)
b) Invalid syntax
c) (7,6)
d) Nothing is printed

 

What will be the output of the following Python code snippet ??

>>> a=(“Check”)*3
>>> a

a) (‘Check’,’Check’,’Check’)
b) * Operator not valid for tuples
c) (‘CheckCheckCheck’)
d) Syntax error

 

What will be the output of following Python code ??

>>>t=(1,2,4,3)
>>>t[1:-1]

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

 

Tuples Python Questions

 

What will be the output of code ??

>>> a=(1,2)
>>> b=(3,4)
>>> c=a+b
>>> c

a) (4,6)
b) (1,2,3,4)
c) Error as tuples are immutable
d) None

 

What will be the output of the following ??

>>> a=(1,2,(4,5))
>>> b=(1,2,(3,4))
>>> a<b

a) False
b) True
c) Error, < operator is not valid for tuples
d) Error, < operator is valid for tuples but not if there are sub-tuples

 

What will be the output of the following Python code ??

>>>t=(1,2,4,3)
>>>t[1:3]

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

 

Tuples Python Questions

 

Is the following Python code valid ??

>>> a,b=1,2,3

a) Yes, this is an example of tuple unpacking. a=1 and b=2
b) Yes, this is an example of tuple unpacking. a=(1,2) and b=3
c) No, too many values to unpack
d) Yes, this is an example of tuple unpacking. a=1 and b=(2,3)

 

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

a) Error, tuple slicing doesn’t exist
b) [2,3]
c) (2,3,4)
d) (2,3)

 

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

 

What will be the output of the following Python code ??

a = (‘check’,)
n = 2
for i in range(int(n)):
a = (a,)
print(a)

a) Error, tuples are immutable

b) ((‘check’,),)
(((‘check’,),),)

c) ((‘check’,)’check’,)

d) ((‘check’,)’check’,)
(((‘check’,)’check’,)’check’,)

 

Tuples Python Questions

 

What is the data type of (1) ??

a) Tuple
b) Integer
c) List
d) Both tuple and integer

 

Which of the following is a Python tuple ??

a) [1, 2, 3]
b) (1, 2, 3)
c) {1, 2, 3}
d) {}

 

Is the following Python code valid ??

>>> a,b,c=1,2,3
>>> a,b,c

a) Yes, [1,2,3] is printed
b) No, invalid syntax
c) Yes, (1,2,3) is printed
d) 1 is printed

Leave a Comment

Your email address will not be published. Required fields are marked *

error: Content is protected !!