Tuples Questions and Answers
Python Programming - Tuples Questions with Answers help learners understand immutable data storage. These Python Tuples Questions are valuable for TCS, Capgemini, and SSC exams, testing sequence data type knowledge
Tuples
Showing 10 of
25 questions
1. Which of the following is the correct way to create a tuple in Python?
- tuple = [1, 2, 3]
- tuple = (1, 2, 3)
- tuple = {1, 2, 3}
- tuple = <1, 2, 3>
2. What is the key characteristic that distinguishes tuples from lists in Python?
- Tuples can store only integers
- Tuples are immutable
- Tuples use square brackets
- Tuples are faster for all operations
3. How do you access the second element in a tuple called my_tuple?
- my_tuple(2)
- my_tuple[1]
- my_tuple[2]
- my_tuple.get(1)
4. Which method is available for tuples in Python?
- append()
- remove()
- count()
- sort()
5. What will be the output of: tuple1 = (1, 2, 3); tuple2 = tuple1 + (4,); print(tuple2)
- (1, 2, 3, 4)
- (1, 2, 3)(4)
- Error
- (1, 2, 3, (4))
6. How do you create a tuple with only one element?
- my_tuple = (5)
- my_tuple = (5,)
- my_tuple = [5]
- my_tuple = tuple(5)
7. Which operation is NOT allowed on tuples?
- Slicing
- Indexing
- del my_tuple[0]
- Concatenation
9. How can you convert a list to a tuple?
- tuple = list.to_tuple()
- tuple = (list)
- tuple = tuple(list)
- tuple = convert(list)
10. What does tuple unpacking allow you to do?
- Add elements to a tuple
- Remove elements from a tuple
- Assign tuple elements to variables
- Change tuple values