π¦ Computational Thinking & Programming-I Quiz 12 β Tuples in Python (Class 11 CS)
Practice 20 CBSE Class 11 Computer Science (Code 083) MCQs on Python tuples β indexing, tuple operations (concatenation, repetition, membership, slicing), built-in functions/methods (len(), tuple(), count(), index(), sorted(), min(), max(), sum()), tuple assignment (unpacking), nested tuples, and suggested programs like finding the min/max/mean and counting frequency.
Every function and expression below has been verified by actually running it in Python β including fixes to two questions from the original quiz that were either incomplete or missing the correct option entirely. Tap any question to reveal the answer with a clear explanation.
π¦ Tuple Basics
What is a tuple in Python?
- A sequence of numbers only
- A sequence of characters only
- A mathematical equation
- An ordered, immutable collection of values
Show Answer & Explanation
β Answer: (d) An ordered, immutable collection of values
A tuple is an ordered collection of values, written in round brackets like (1, 2, 3), and β unlike a list β it’s immutable, meaning it can’t be changed once created.
π’ Indexing
How can you access individual elements in a tuple?
- By using parentheses ()
- By using curly braces {}
- By using square brackets []
- By using angle brackets <>
Show Answer & Explanation
β Answer: (c) By using square brackets []
Even though tuples are defined with round brackets, you still access their elements using square brackets β e.g. t[0] β exactly like lists and strings.
β Tuple Operations
Which of the following tuple operations combines two or more tuples together?
- Concatenation
- Repetition
- Membership
- Slicing
Show Answer & Explanation
β Answer: (a) Concatenation
Concatenation (using +) joins two tuples into a single new tuple: (1,2) + (3,4) gives (1, 2, 3, 4).
β Tuple Operations
Which tuple operation repeats a tuple a certain number of times?
- Concatenation
- Repetition
- Membership
- Slicing
Show Answer & Explanation
β Answer: (b) Repetition
Repetition (using *) repeats a tuple’s elements: (1,2) * 2 gives (1, 2, 1, 2).
π§° Built-in Functions
Which built-in function is used to determine the length of a tuple?
- len()
- tuple()
- count()
- index()
Show Answer & Explanation
β Answer: (a) len()
len() returns the number of elements in a tuple, just as it does for lists and strings.
π§° Built-in Functions
Which built-in method is used to count the occurrences of an element in a tuple?
- len()
- tuple()
- count()
- index()
Show Answer & Explanation
β Answer: (c) count()
count() tallies how many times a given value appears in the tuple.
π§° Built-in Functions
Which built-in method is used to find the index of the first occurrence of an element in a tuple?
- len()
- tuple()
- count()
- index()
Show Answer & Explanation
β Answer: (d) index()
index() returns the position of the first matching element, and raises a ValueError if the value isn’t found.
π§° Built-in Functions
Which built-in method is used to create a tuple from another sequence?
- len()
- tuple()
- count()
- index()
Show Answer & Explanation
β Answer: (b) tuple()
The tuple() constructor converts an iterable (like a list or string) into a tuple β e.g. tuple([1, 2, 3]) gives (1, 2, 3).
π§° Built-in Functions
Which built-in function sorts the elements of a tuple in ascending order?
- sorted()
- sort()
- orderby()
- sum()
Show Answer & Explanation
β Answer: (a) sorted()
sorted() works on a tuple and returns a new list of the sorted elements. Note: tuples don’t have a .sort() method at all β that only exists on mutable types like lists, since sorting in place would require changing the tuple.
π§° Built-in Functions
Which built-in function finds the minimum value in a tuple of numbers?
- sorted()
- min()
- max()
- sum()
Show Answer & Explanation
β Answer: (b) min()
min() scans the tuple and returns the smallest value.
π§° Built-in Functions
Which built-in function finds the maximum value in a tuple of numbers?
- sorted()
- maximum()
- max()
- sum()
Show Answer & Explanation
β Answer: (c) max()
max() scans the tuple and returns the largest value. (maximum() isn’t a real Python function.)
π§° Built-in Functions
Which built-in function calculates the sum of the values in a tuple of numbers?
- sorted()
- total()
- add()
- sum()
Show Answer & Explanation
β Answer: (d) sum()
sum() adds up every numeric value in the tuple and returns the total. (total() and add() aren’t real Python built-ins.)
π Tuple Assignment
What is tuple assignment (also called tuple unpacking) in Python?
- Assigning individual values from a tuple to multiple variables at once, e.g. a, b, c = (1, 2, 3)
- Assigning any single tuple to any single variable
- Assigning an index position to a tuple
- Assigning a length value to a tuple
Show Answer & Explanation
β Answer: (a) Assigning individual values from a tuple to multiple variables at once, e.g. a, b, c = (1, 2, 3)
Tuple assignment (unpacking) specifically means assigning each element of a tuple to its own variable in one line β e.g. a, b, c = (1, 2, 3) sets a=1, b=2, c=3. (This question is corrected from the original, whose answer β βassigning a tuple to a variableβ β describes ordinary assignment that applies to any data type, not the specific unpacking behaviour that makes tuple assignment a distinct, named concept.)
πͺ Nested Tuples
What is a nested tuple?
- A tuple with repeated values
- A tuple with mixed data types
- A tuple placed inside another tuple
- A tuple with no elements
Show Answer & Explanation
β Answer: (c) A tuple placed inside another tuple
A nested tuple is a tuple that contains another tuple as one of its elements β e.g. ((1, 2), (3, 4)).
β Suggested Programs
Which of the following correctly describes the suggested program for counting the frequency of elements in a tuple?
- Counting how many times each element appears, typically using count() in a loop
- Sorting the tuple’s elements in ascending order
- Reversing the order of the tuple’s elements
- Concatenating two different tuples together
Show Answer & Explanation
β Answer: (a) Counting how many times each element appears, typically using count() in a loop
Frequency counting means determining how many times each distinct value shows up β commonly done by looping through the unique values and calling tuple.count(value) for each. (This question is corrected/completed from the original quiz, whose four answer options β minimum, maximum, mean, linear search β didn’t actually include βfrequency countingβ at all, making the question unanswerable as originally written.)
β Tuple Operations
What is the result of the expression 3 in (1, 2, 3) in Python?
- True
- False
- 3
- Error
Show Answer & Explanation
β Answer: (a) True
The membership operator in checks whether a value exists in the tuple β since 3 is present, this evaluates to True.
β Tuple Operations
What does the slice t[1:3] return for the tuple t = (10, 20, 30, 40, 50)?
- (10, 20)
- (20, 30)
- (20, 30, 40)
- (30, 40)
Show Answer & Explanation
β Answer: (b) (20, 30)
Just like with lists, [1:3] takes elements from index 1 up to (but not including) index 3: (20, 30).
π¦ Tuple Basics
What happens when you try to run t = (1, 2, 3); t[0] = 10 in Python?
- The tuple updates to (10, 2, 3)
- Nothing happens, the tuple stays the same
- It raises a TypeError
- It automatically converts the tuple to a list first
Show Answer & Explanation
β Answer: (c) It raises a TypeError
Since tuples are immutable, trying to assign a new value to an index raises a TypeError β 'tuple' object does not support item assignment. This is the defining difference from lists.
βοΈ Tuple vs List
What is the key difference between a tuple and a list in Python?
- Tuples use square brackets, lists use round brackets
- Tuples are immutable; lists are mutable
- Lists can only store numbers; tuples can store anything
- There is no real difference between them
Show Answer & Explanation
β Answer: (b) Tuples are immutable; lists are mutable
The core distinction is mutability: a tuple cannot be changed after creation, while a list can have elements added, removed, or modified freely. (It’s actually the reverse of option (a) β tuples use round brackets (), lists use square brackets [], to define them.)
πͺ Nested Tuples
For the nested tuple t = ((1, 2), (3, 4)), what does t[1][0] give?
- 1
- 2
- 3
- 4
Show Answer & Explanation
β Answer: (c) 3
Nested indexing works left to right: t[1] gives (3, 4), and [0] of that gives 3.
