Python Tuple Quiz

Python Tuple Quiz

This is a quiz regarding the Python Tuple.

Topics covered in this quiz :

  1. Python Tuples
  2. Tuple Indexing and Slicing
  3. Tuple Operations
  4. Tuple Unpacking
  5. Loop Through Tuple
  6. Tuple Methods

1) What is the output of the below Python code?
tup = (2,4,3,8,5)
print(max(tup*2))

2) What is the output of the below Python code?
tup = (2,4)
print(tup*2)

3) What is the output of the below Python code?
tup = (2,4,6,8)
tup.extend((9,10,11))
print(tup)

4) What is the output of the below Python code?
a = "a","b","c","d"
print(a)

5) What is the output of the below Python code?
tup = (2,4,6,8)
print(tup[-1])

6) Python Tuple is mutable?

7) What is the output of the below Python code?
tup = (2,4,6,8)
tup[1] = 9
print(tup)

8) What is the correct way to create a tuple?

9) Select the statements that will create the tuple.

10) How can we create a tuple with single element 5?

11) Which operation on the tuple t will work fine?
t = (1,2,3,4)

12) What is the output of the following code?

t = ()
t2 = t * 3
print(len(t2))

13) What is the output of the following code?

t = (2)
t2 = t * 3
print(len(t2))

14) What is the output of the following code?

t = (3,)
t2 = t * 3
print(len(t2))

15) What is the output of the following code?

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

16) Which method/function will result in error with nested tuples?

17) What is the output of the following code?

tup = ((1,2,3,(4,5)),6)
print(len(tup))

Your score is

The average score is 62%

0%