Python tuples and sets are fundamental built-in data structures used to store collections of items with distinct characteristics. Tuples are ordered, immutable sequences enclosed in parentheses, making them hashable and efficient for fixed data or dictionary keys. Conversely, sets are unordered collections of unique, mutable elements optimized for mathematical operations like unions, intersections, and membership testing. Mastery of both structures is crucial for writing clean, high-performance, and bug-free Python code in data science, software development, and technical interviews.
Python Tuples & Sets MCQs
1 min read
Correct Answer: c) Tuple
Explanation:
Tuples are immutable sequences, meaning their elements cannot be changed after creation.
Correct Answer: c) t = ()
Explanation:
An empty tuple is created using empty parentheses.
Correct Answer: b) t = (5,)
Explanation:
A single-element tuple requires a trailing comma so Python distinguishes it from a parenthesized expression.
Correct Answer: c) Set
Explanation:
Sets are mutable collections that store unique, unhashed elements.
Correct Answer: b) s = set()
Explanation:
{} creates an empty dictionary, so an empty set must be created using set().
Correct Answer: b) TypeError
Explanation:
Tuples do not support item assignment, raising a TypeError.
Correct Answer: c) add()
Explanation:
The add() method adds a single element to a set.
Correct Answer: b) remove()
Explanation:
remove() removes the specified element and raises a KeyError if missing, whereas discard() does not.
Correct Answer: b) 5
Explanation:
len() returns the total number of items in the tuple, including duplicates.
Correct Answer: a) Concatenation using +
Explanation:
Tuples support concatenation and repetition operators, but not in-place modification methods.
Correct Answer: b) Assigning multiple values to a single variable without parentheses
Explanation:
Tuple packing is the act of placing values into a tuple without explicit parentheses.
Correct Answer: b) Extracting tuple elements into individual variables
Explanation:
Unpacking allows you to extract elements of a tuple into distinct variable names.
Correct Answer: b) count()
Explanation:
The count() method returns the number of times a specified value appears in a tuple.
Correct Answer: c) index()
Explanation:
The index() method returns the index of the first matching element.
Correct Answer: b) Yes, the tuple itself is immutable, but the contained mutable objects can be modified.
Explanation:
Tuple immutability refers to its references, so mutable contents inside it can still change.
Correct Answer: c) Tuple
Explanation:
Set elements must be hashable. Tuples are hashable (if their contents are), while lists, sets, and dicts are unhashable.
Correct Answer: b) {1, 2, 3}
Explanation:
Sets automatically eliminate duplicate values.
Correct Answer: b) |
Explanation:
The pipe symbol (|) is the union operator for sets.
Correct Answer: b) &
Explanation:
The ampersand symbol (&) is the intersection operator for sets.
Correct Answer: a) -
Explanation:
The minus sign (-) returns elements in the first set that are not in the second set.
Correct Answer: c) ^
Explanation:
The caret symbol (^) returns elements that are in either set, but not in both.
Correct Answer: c) Does nothing
Explanation:
discard() safely removes an element if present and does nothing if it is absent.
Correct Answer: b) Removes and returns an arbitrary element
Explanation:
Because sets are unordered, pop() removes and returns an arbitrary element.
Correct Answer: b) clear()
Explanation:
The clear() method empties the set completely.
Correct Answer: a) A.issubset(B)
Explanation:
issubset() checks whether all elements of A are present in B.
Correct Answer: a) isdisjoint()
Explanation:
isdisjoint() returns True if two sets have a null intersection.
Correct Answer: b) An immutable version of a set
Explanation:
A frozenset is immutable and hashable, meaning it can be used as a dictionary key or set element.
Correct Answer: b) <class 'tuple'>
Explanation:
The trailing comma ensures it is parsed as a tuple.
Correct Answer: b) <class 'int'>
Explanation:
Without a trailing comma, parentheses are treated as mathematical grouping, making it an integer.
Correct Answer: b) Yes, because tuples are hashable.
Explanation:
Because tuples are immutable and hashable, they can be used as dictionary keys.
Correct Answer: b) No, because sets are mutable and unhashable.
Explanation:
Standard sets are mutable and unhashable, so they cannot be dictionary keys.
Correct Answer: a) ('a', 'b', 'c')
Explanation:
The tuple() constructor converts an iterable (like a string) into a tuple of its characters.
Correct Answer: a) {'b', 'a', 'n'}
Explanation:
set() splits the string into unique characters.
Correct Answer: b) update()
Explanation:
The update() method adds elements from any iterable to the set.
Correct Answer: b) A sorted list
Explanation:
The built-in sorted() function always returns a new list regardless of the input iterable type.
Correct Answer: a) tuple(range(5))
Explanation:
tuple() accepts an iterable like range(5) to construct the tuple.
Correct Answer: b) O(1)
Explanation:
Sets are implemented as hash tables, making average-case membership lookups O(1).
Correct Answer: b) O(n)
Explanation:
Tuples are linear sequences, so membership testing requires a linear scan O(n).
Correct Answer: b) (1, 2, 1, 2, 1, 2)
Explanation:
The repetition operator (*) repeats the tuple contents the specified number of times.
Correct Answer: b) Tuples support both positive and negative indexing.
Explanation:
Like lists and strings, tuples support positive indexing from the start and negative indexing from the end.
Correct Answer: b) (2, 3)
Explanation:
Slicing `[1:]` starts from index 1 to the end of the tuple.
Correct Answer: b) Yes, `del` can delete the entire tuple reference.
Explanation:
You cannot delete individual items of a tuple, but you can delete the entire tuple object itself.
Correct Answer: b) The set remains unchanged
Explanation:
Sets store unique elements; adding an existing element has no effect.
Correct Answer: c) max()
Explanation:
The max() function returns the largest item in an iterable.
Correct Answer: c) 5
Explanation:
min() returns the smallest element in the tuple.
Correct Answer: a) {x for x in range(5)}
Explanation:
Curly braces with a comprehension expression generate a set.
Correct Answer: c) A generator object
Explanation:
Parentheses with a comprehension create a generator object, not a tuple.
Correct Answer: b) list(set_obj)
Explanation:
Passing a set to the list() constructor converts it to a list.
Correct Answer: b) No, sets are completely unordered.
Explanation:
Standard sets do not guarantee any specific order of elements.
Correct Answer: c) Tuples support in-place item sorting via sort().
Explanation:
Tuples do not have a sort() method because they are immutable.
Correct Answer: b) (1, 2, 3, 4)
Explanation:
The plus operator (+) concatenates two tuples into a new tuple.
Correct Answer: b) {2, 3}
Explanation:
The intersection operator (&) returns elements common to both sets.
Correct Answer: a) {1}
Explanation:
Set difference returns elements in the first set that are not present in the second set.
Correct Answer: b) {1, 3}
Explanation:
Symmetric difference returns elements present in either set, but not in both.
Correct Answer: a) intersection_update()
Explanation:
intersection_update() keeps only elements found in both sets.
Correct Answer: a) difference_update()
Explanation:
difference_update() removes the items specified in another set from the current set.
Correct Answer: a) symmetric_difference_update()
Explanation:
symmetric_difference_update() updates the set with elements from either set, but not both.
Correct Answer: a) issuperset()
Explanation:
issuperset() checks if all elements of another set are contained within the set.
Correct Answer: b) Creates a shallow copy
Explanation:
copy() returns a shallow copy of the set.
Correct Answer: b) No, it raises a ValueError.
Explanation:
Mismatching the number of variables and tuple elements during unpacking raises a ValueError.
Correct Answer: a) Using the * operator (star assignment)
Explanation:
Star unpacking (e.g., `a, *b, c = my_tuple`) captures remaining elements into a list.
Correct Answer: a) Tuples use less memory and are faster to instantiate.
Explanation:
Due to their immutable nature, Python optimizes tuple allocation and memory usage.
Correct Answer: a) 10
Explanation:
sum() adds up all the numeric items in the tuple.
Correct Answer: b) all()
Explanation:
all() returns True if all elements of the iterable are true (or if the iterable is empty).
Correct Answer: a) any()
Explanation:
any() returns True if at least one element of the iterable is true.
Correct Answer: b) No, frozensets are immutable.
Explanation:
Frozensets cannot be modified after they are created.
Correct Answer: b) Yes, because frozensets are hashable.
Explanation:
Because frozensets are hashable, they can be elements of other sets or frozensets.
Correct Answer: b) It raises a TypeError.
Explanation:
Set elements must be hashable; unhashable items like lists trigger a TypeError.
Correct Answer: a) t[-1]
Explanation:
-1 refers to the final element in Python sequences.
Correct Answer: b) False
Explanation:
Tuple equality checks both values and order. Different orders evaluate to False.
Correct Answer: a) True
Explanation:
Sets are unordered collections, so two sets with the same elements are equal regardless of order.
Correct Answer: b) It swaps the values of a and b using tuple packing and unpacking.
Explanation:
Python evaluates the right side as a packed tuple and unpacks it to the left side, swapping values cleanly.
Correct Answer: c) zip object (iterator)
Explanation:
zip() returns an iterator of tuples.
Correct Answer: b) list(dict.fromkeys(my_list))
Explanation:
dict.fromkeys() preserves insertion order in modern Python versions while removing duplicates.
Correct Answer: b) KeyError
Explanation:
Calling pop() on an empty set raises a KeyError.
Correct Answer: b) Yes, tuples can contain other tuples (nested tuples).
Explanation:
Tuples can contain any valid Python objects, including other tuples.
Correct Answer: a) union()
Explanation:
The union() method returns a new set with all elements from the sets involved.
Correct Answer: a) intersection()
Explanation:
The intersection() method returns a new set with elements common to all specified sets.
Correct Answer: a) difference()
Explanation:
The difference() method returns a new set with elements in the first set but not in others.
Correct Answer: a) symmetric_difference()
Explanation:
symmetric_difference() returns elements in either set, but not in both.
Correct Answer: b) False
Explanation:
Empty collections (tuples, lists, sets, dicts) evaluate to False in boolean contexts.
Correct Answer: b) False
Explanation:
An empty set evaluates to False.
Correct Answer: a) True
Explanation:
Non-empty collections evaluate to True.
Correct Answer: b) (1, 2, 3)
Explanation:
The tuple() constructor converts a list into a tuple.
Correct Answer: c) {1, 2, 3}
Explanation:
The set() constructor removes duplicates and creates a set.
Correct Answer: c) A frozenset
Explanation:
Frozensets are immutable and hashable, so they can be elements of another set.
Correct Answer: c) TypeError
Explanation:
You can only concatenate a tuple with another tuple, not with an integer.
Correct Answer: b) 0
Explanation:
An empty set has a length of 0.
Correct Answer: a) t = 1, 2, 3
Explanation:
Comma-separated values without brackets or braces implicitly form a tuple.
Correct Answer: a) Using * syntax
Explanation:
The * operator unpacks a tuple into positional arguments for a function call.
Correct Answer: a) True
Explanation:
The `in` operator checks for the presence of an element in the tuple.
Correct Answer: a) True
Explanation:
`not in` returns True because 3 is not present in the set.
Correct Answer: a) t[::-1]
Explanation:
Slice notation with a step of -1 (`[::-1]`) reverses a tuple and returns a new tuple.
Correct Answer: b) A reversed iterator object
Explanation:
reversed() returns an iterator, which can then be converted to a tuple or list.
Correct Answer: a) Set methods like intersection() accept any iterable, whereas operator & requires both operands to be sets.
Explanation:
Set methods accept any iterable as arguments, while operators require set instances on both sides.
Correct Answer: b) 9
Explanation:
max() evaluates the set and returns the highest value.
Correct Answer: b) No, because sets are unordered.
Explanation:
Slicing requires sequential, ordered positions, so it fails on unordered collections like sets.
Correct Answer: b) It returns an integer hash value.
Explanation:
Because tuples are hashable, the hash() function successfully calculates their hash.
Correct Answer: b) It raises a TypeError because the contained list is unhashable.
Explanation:
A tuple is only hashable if all its individual elements are also hashable.
Correct Answer: b) len(s)
Explanation:
The built-in len() function returns the number of items in a set.
Correct Answer: b) They are implemented using hash tables.
Explanation:
Python sets use hash tables under the hood to ensure uniqueness and fast lookups.
Correct Answer: b) An empty tuple
Explanation:
Calling tuple() without arguments creates an empty tuple.
Related Posts

Java Advanced MCQs
Advanced Java encompasses complex programming paradigms, low-level runtime mechanics, and high-performance framework design beyond standard syntax. It probes deep into…
October 19, 2026By MCQs Generator
No Image
400+ C++ Interview Questions MCQ
1. Which of the following data structures is immutable in Python? a) List b) Set c) Tuple d) Dictionary Show…
October 19, 2026By MCQs Generator

Java Variables & Data Types MCQs
Variables in Java act as named memory containers used to store data values during program execution, while data types define…
October 19, 2026By MCQs Generator
Related Categories

AI & Data Science MCQ
5 topics
By MCQs Generator

Arts & Humanities MCQ
4 topics
By MCQs Generator

Civil Engineering MCQ
4 topics
By MCQs Generator

Commerce & Business MCQ
4 topics
By MCQs Generator

Competitive Exams MCQ
5 topics
By MCQs Generator

Electrical & Electronics Engineering MCQ
3 topics
By MCQs Generator

General Knowledge MCQ
2 topics
By MCQs Generator

General Science MCQ
4 topics
By MCQs Generator

Law & Judiciary MCQ
3 topics
By MCQs Generator

Mechanical Engineering MCQ
4 topics
By MCQs Generator

Medical & Health Sciences MCQ
4 topics
By MCQs Generator

Modern Tech Fields MCQ
3 topics
By MCQs Generator