You are on page 1of 2

Tuple Assessment

1. What is a tuple in Python?


a) A mutable collection of items
b) An immutable collection of items
c) A method to organize data
d) A data type for numerical values

2. How do you create a tuple with only one element?


a) t = (5)
b) t = 5,
c) t = (5,)
d) Both b and c

3. What is the output of the following code?


t = (1, 2, 3, 4)
print(t[1:3])
a) 1, 2
b) 1, 2, 3
c) 2, 3
d) 3, 4

4. What is the output of the following code?


t = (1, 2, 3, 4)
print(t.index(3))
a) 0
b) 1
c) 2
d) 3

5. How can you delete an entire tuple?


a) Using the del keyword
b) Using the remove() method
c) Using the pop() method
d) Tuples cannot be deleted

6. Which of the following methods is not applicable to tuples?


a) count()
b) index()

Tuple Assessment 1
c) append()
d) Both a and b

7. What will be the output of the following code?


t1 = (1, 2, 3)
t2 = (4, 5, 6)
t3 = t1 + t2
print(t3)
a) (5, 7, 9)
b) (1, 2, 3, 4, 5, 6)
c) (1, 4, 2, 5, 3, 6)
d) Error

8. Which of the following is the correct way to unpack a tuple?


a) a, b, c = t
b) a, *b, c = t
c) a, b, c = *t
d) Both a and b

9. What is the output of the following code?


t = (1, 2, 3, 4)
t = t[:2] + (5,) + t[2:]
print(t)
a) (1, 2, 5, 3, 4)
b) (1, 2, 5)
c) (1, 2, 3, 5)
d) Error

10. How do you create an empty tuple?


a) t = ( )
b) t = [ ]
c) t = empty_tuple( )
d) t = { }

Tuple Assessment 2

You might also like