Class 9 Computer Science: Lists & Tuples
This worksheet challenges your understanding of Python lists and tuples, focusing on their manipulation, differences, and common operations. Prepare to tackle advanced scenarios.
Class 9CBSEComputer SciencehardPractice
Preview · 10 questions
- Q1. What is the primary difference in mutability between Python lists and tuples?
- Lists are mutable, tuples are immutable.
- Lists are immutable, tuples are mutable.
- Both lists and tuples are mutable.
- Both lists and tuples are immutable.
- Q2. Which of the following methods can be used to add an element to the end of an existing list?
- list.insert()
- list.extend()
- list.append()
- list.add()
- Q3. Given a tuple `t = (1, 2, 3)`, what will `t[1:3]` evaluate to?
- (2, 3)
- (1, 2)
- (1, 3)
- Error
- Q4. Which of the following statements is true regarding nested lists and nested tuples?
- A list can contain tuples, but a tuple cannot contain lists.
- A tuple can contain lists, but a list cannot contain tuples.
- Both lists and tuples can contain other lists and tuples.
- Neither lists nor tuples can contain other complex data types.
- Q5. Consider the code: `my_list = [5, 2, 8, 1, 9]`. What will `my_list.sort()` do to `my_list`?
- Return a new sorted list.
- Sort the list in-place in ascending order.
- Sort the list in-place in descending order.
- Raise an error because sort() requires arguments.
+ 5 more in the printable PDF.