Tuples Questions and Answers
Practice ModeShowing 10 of 25 questions
Q21
What is the result of: my_tuple = (1, 2, 3); print(my_tuple[-1])
Answer: Option C
Explanation: Negative indexing starts from the end of the tuple, with -1 being the last element.
Q22
How do you count occurrences of an element in a tuple?
Answer: Option B
Explanation: The count() method returns the number of times a specified value appears in the tuple.
Q23
What is tuple comparison?
Answer: Option B
Explanation: Tuples can be compared using comparison operators. Comparison is done element by element.
Q24
What will be the output of: tuple1 = (1, 2); tuple2 = (1, 2); print(tuple1 == tuple2)
Answer: Option A
Explanation: Tuples with the same elements in the same order are considered equal.
Q25
Why are tuples used as keys in dictionaries while lists are not?
Answer: Option B
Explanation: Dictionary keys must be hashable (immutable). Tuples are immutable and therefore hashable, while lists are mutable and not hashable.