Welcome to the Python Tuples Quiz!
Tuples in Python are immutable, ordered collections that can store multiple items of different data types. Unlike lists, tuples cannot be modified after creation, making them useful for storing fixed data. This quiz will test your understanding of Python tuples, covering their properties, methods, and common use cases.
Each question is followed by the correct answer. Good luck!
Table of Contents:
Python quizzes for beginners series
Tuples Quiz
Quiz Questions
Basic Concepts
What is a tuple in Python?a) A mutable listb) An immutable ordered collectionc) A dictionaryd) A set
Answer
b) An immutable ordered collection
Which of the following correctly creates a tuple?a) tup = (1, 2, 3)b) tup = [1, 2, 3]c) tup = {1, 2, 3}d) tup = “1, 2, 3”
Answer
a) tup = (1, 2, 3)
What will type((10,)) return?a) <class ‘list’>b) <class ‘tuple’>c) <class ‘int’>d) <class ‘dict’>
Answer
b) <class ‘tuple’>
Which method can be used to count occurrences of an element in a tuple?a) count()b) index()c) find()d) exists()
Answer
a) count()
How do you access the last element of a tuple t = (5, 10, 15, 20)?a) t[-1]b) t[3]c) t[len(t) – 1]d) All of the above
Answer
d) All of the above
Tuple Properties & Operations
Can a tuple contain duplicate values?a) Yesb) No
Answer
a) Yes
Which of the following will create an empty tuple?a) tup = ()b) tup = tuple()c) tup = {}d) Both a and b
Answer
d) Both a and b
Tuples are faster than lists in Python.a) Trueb) False
Answer
a) True
What will happen if you try to modify a tuple?a) It will change the value successfullyb) It will raise a TypeErrorc) It will create a new tuple with the modified valued) It will return None
Answer
b) It will raise a TypeError
How can you concatenate two tuples t1 = (1, 2) and t2 = (3, 4)?a) t1 + t2b) t1.extend(t2)c) t1.append(t2)d) concat(t1, t2)
Answer
a) t1 + t2
Tuple Indexing & Slicing
What is the output of t = (1, 2, 3, 4, 5)[1:4]?a) (2, 3, 4)b) (1, 2, 3, 4)c) (2, 3, 4, 5)d) (3, 4, 5)
Answer
a) (2, 3, 4)
What happens if you try t[100] on t = (10, 20, 30)?a) Returns Noneb) Raises IndexErrorc) Returns 0d) Prints nothing
Answer
b) Raises IndexError
What is the result of t[::-1] for t = (1, 2, 3, 4)?a) (1, 2, 3, 4)b) (4, 3, 2, 1)c) (1, 4, 3, 2)d) Syntax error
Answer
b) (4, 3, 2, 1)
Tuple Methods & Functions
How do you find the length of a tuple t = (1, 2, 3, 4, 5)?a) size(t)b) length(t)c) len(t)d) count(t)
Answer
c) len(t)
Which function converts a list into a tuple?a) list()b) tuple()c) set()d) dict()
Answer
b) tuple()
How do you check if an element exists in a tuple?a) exists()b) inc) find()d) contains()
Answer
b) in
Advanced Tuple Concepts
What is tuple unpacking?a) Extracting values from a tuple into separate variablesb) Combining two tuples into onec) Deleting elements from a tupled) Sorting a tuple
Answer
a) Extracting values from a tuple into separate variables
What will the following code output?
t = (1, 2, [3, 4])t[2][0] = 99print(t)
a) (1, 2, [99, 4])b) (1, 2, [3, 4])c) TypeErrord) (1, 2, 99, 4)
Answer
a) (1, 2, [99, 4])
Which of the following is true?a) Tuples use less memory than listsb) Tuples are faster than listsc) Tuples are immutabled) All of the above
Answer
d) All of the above
Which built-in function allows you to iterate over a tuple while keeping track of the index?a) enumerate()b) zip()c) range()d) map()
Answer
a) enumerate()
How did you do? 🎯
18-20 correct → 🏆 Excellent! You’re a Python functions pro!
14-17 correct → 👍 Great job! Keep practicing.
10-13 correct → 🙂 Good, but there’s room for improvement.
Below 10 → 🤔 No worries! Review the concepts and try again.