Tuples Questions and Answers

Practice Mode
Showing 10 of 25 questions
Q11
What will be the output of: my_tuple = (1, 2, 3); my_tuple[1] = 5
  • A (1, 5, 3)
  • B (5, 2, 3)
  • C TypeError
  • D (1, 2, 3)
Answer: Option C
Explanation: Tuples are immutable, so you cannot change their elements once created. This will raise a TypeError.
Q12
Which of these is a valid tuple declaration?
  • A my_tuple = (1, "hello", 3.14)
  • B my_tuple = [1, "hello", 3.14]
  • C my_tuple = {1, "hello", 3.14}
  • D my_tuple = 1, "hello", 3.14
Answer: Option A
Explanation: Tuples can contain mixed data types and are defined with parentheses.
Q13
How do you find the index of an element in a tuple?
  • A my_tuple.find(2)
  • B my_tuple.index(2)
  • C my_tuple.search(2)
  • D my_tuple.position(2)
Answer: Option B
Explanation: The index() method returns the first occurrence of the specified value.
Q14
What is tuple repetition?
  • A Creating multiple copies of a tuple
  • B Removing duplicate elements
  • C Sorting tuple elements
  • D Merging two tuples
Answer: Option A
Explanation: Tuple repetition uses the * operator to repeat the tuple elements a specified number of times.
Q15
What will be the output of: my_tuple = (1, 2, 3) * 2
  • A (1, 2, 3, 1, 2, 3)
  • B (2, 4, 6)
  • C (1, 2, 3, 2)
  • D Error
Answer: Option A
Explanation: The * operator repeats the tuple elements the specified number of times.
Q16
How do you check if an element exists in a tuple?
  • A my_tuple.exists(2)
  • B 2 in my_tuple
  • C my_tuple.contains(2)
  • D 2 is in my_tuple
Answer: Option B
Explanation: The 'in' keyword is used to check for membership in tuples and other sequences.
Q17
What is the result of: my_tuple = (5,); print(type(my_tuple))
  • A <class 'int'>
  • B <class 'tuple'>
  • C <class 'list'>
  • D <class 'str'>
Answer: Option B
Explanation: The comma makes it a tuple. Without comma, it would be an integer.
Q18
How can you delete an entire tuple?
  • A my_tuple.clear()
  • B del my_tuple
  • C my_tuple.delete()
  • D remove my_tuple
Answer: Option B
Explanation: While individual elements cannot be deleted, the entire tuple can be deleted using the del statement.
Q19
What will be the output of: my_tuple = (1, 2, 3, 4, 5); print(my_tuple[1:4])
  • A (1, 2, 3)
  • B (2, 3, 4)
  • C (2, 3, 4, 5)
  • D (1, 2, 3, 4)
Answer: Option B
Explanation: Tuple slicing works similarly to list slicing, returning a new tuple with the specified range.
Q20
Which of the following is true about nested tuples?
  • A Tuples cannot contain other tuples
  • B Nested tuples are not allowed in Python
  • C Tuples can contain other tuples
  • D Only lists can be nested in tuples
Answer: Option C
Explanation: Tuples can contain other tuples as elements, creating nested structures.
Questions and Answers for Competitive Exams Various Entrance Test