Tuples Questions and Answers
Practice ModeShowing 10 of 25 questions
Q11
What will be the output of: my_tuple = (1, 2, 3); my_tuple[1] = 5
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?
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?
Answer: Option B
Explanation: The index() method returns the first occurrence of the specified value.
Q14
What is tuple repetition?
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
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?
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))
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?
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])
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?
Answer: Option C
Explanation: Tuples can contain other tuples as elements, creating nested structures.