Tuples Questions and Answers
Practice ModeShowing 10 of 25 questions
Q1
Which of the following is the correct way to create a tuple in Python?
Answer: Option B
Explanation: Tuples are created using parentheses () or the tuple() constructor. Lists use square brackets [] and dictionaries use curly braces {}.
Q2
What is the key characteristic that distinguishes tuples from lists in Python?
Answer: Option B
Explanation: Tuples are immutable while lists are mutable. This means tuple elements cannot be changed after creation.
Q3
How do you access the second element in a tuple called my_tuple?
Answer: Option B
Explanation: Tuple elements are accessed using zero-based indexing with square brackets.
Q4
Which method is available for tuples in Python?
Answer: Option C
Explanation: Tuples have limited methods compared to lists. count() and index() are the main methods available.
Q5
What will be the output of: tuple1 = (1, 2, 3); tuple2 = tuple1 + (4,); print(tuple2)
Answer: Option A
Explanation: Tuples can be concatenated using the + operator. Adding (4,) creates a new tuple with the additional element.
Q6
How do you create a tuple with only one element?
Answer: Option B
Explanation: For single-element tuples, a comma is required after the element to distinguish it from a regular expression in parentheses.
Q7
Which operation is NOT allowed on tuples?
Answer: Option C
Explanation: Tuples are immutable, so you cannot modify existing elements. del my_tuple[0] would try to delete an element, which is not allowed.
Q8
What is the result of: my_tuple = (1, 2, 3); print(len(my_tuple))
Answer: Option C
Explanation: The len() function returns the number of elements in the tuple.
Q9
How can you convert a list to a tuple?
Answer: Option C
Explanation: The tuple() constructor can convert any iterable (like lists) to a tuple.
Q10
What does tuple unpacking allow you to do?
Answer: Option C
Explanation: Tuple unpacking allows assigning tuple elements to individual variables in a single statement.