Tuples Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q21
What is the result of: my_tuple = (1, 2, 3); print(my_tuple[-1])
  • A 1
  • B 2
  • C 3
  • D Error
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?
  • A my_tuple.occurrences(2)
  • B my_tuple.count(2)
  • C my_tuple.find_all(2)
  • D count(my_tuple, 2)
Answer: Option B
Explanation: The count() method returns the number of times a specified value appears in the tuple.
Q23
What is tuple comparison?
  • A Comparing memory addresses
  • B Element-by-element comparison
  • C Comparing only lengths
  • D Tuples cannot be compared
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)
  • A True
  • B False
  • C Error
  • D None
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?
  • A Tuples are faster
  • B Tuples are immutable and hashable
  • C Lists take more memory
  • D Tuples have better methods
Answer: Option B
Explanation: Dictionary keys must be hashable (immutable). Tuples are immutable and therefore hashable, while lists are mutable and not hashable.
Questions and Answers for Competitive Exams Various Entrance Test