SAGAR INTERNATIONAL SCHOOL,
PERUNDURAI.
AFFILIATED NO: 1930419
WORKSHEET
CLASS: XI B,C
SUBJECT: COMPUTER SCIENCE
Chapter: Data Handling
Section 1: Multiple Choice Questions (MCQs)
1. Which of the following is a correct way to declare a list in
Python?
a) list = (1, 2, 3)
b) list = [1, 2, 3]
c) list = {1, 2, 3}
d) list = <1, 2, 3>
2. What is the output of: print(type({'a':1, 'b':2}))?
a) <class 'list'>
b) <class 'tuple'>
c) <class 'dict'>
d) <class 'set'>
3. Which method is used to add a key-value pair in a dictionary?
a) add()
b) insert()
c) update()
d) append()
4. What does the `pop()` method do in a dictionary?
a) Removes an arbitrary item
b) Removes the specified key and returns its value
c) Returns the keys
d) Adds a new item
5. What is the output of: print(len({'x':10, 'y':20}))?
a) 0
b) 2
c) 1
d) Error
6. Which of the following is a mutable data type?
a) tuple
b) string
c) list
d) int
7. What is the correct syntax to create a set in Python?
a) s = [1, 2, 3]
b) s = {1, 2, 3}
c) s = (1, 2, 3)
d) s = <1, 2, 3>
8. Which of these data structures stores unordered collections of
unique elements?
a) list
b) tuple
c) set
d) dictionary
9. How do you access the value associated with key 'name' in a
dictionary d?
a) d['name']
b) d.get('name')
c) Both a and b
d) d.name
10. What will the following code print?
d = {'a':1, 'b':2}
print(d.get('c', 3))
a) None
b) 3
c) Error
d) 'c'
11. Which of the following is used to create an empty dictionary?
a) {}
b) []
c) set()
d) ()
12. Which operator is used to check if a key exists in a dictionary?
a) in
b) has
c) contains
d) exists
13. What is the output of:
s = {1, 2, 3}
s.add(4)
print(len(s))
a) 3
b) 4
c) 5
d) Error
14. How do you remove duplicates from a list lst?
a) set(lst)
b) list(set(lst))
c) Both a and b
d) lst.remove_duplicates()
15. Which method returns a list of dictionary keys?
a) keys()
b) items()
c) values()
d) get()
16. What will be the output of:
lst = [1, 2, 3]
print(lst[1])
a) 1
b) 2
c) 3
d) Error
17. Which of the following is NOT a valid dictionary method?
a) popitem()
b) update()
c) append()
d) clear()
18. What is the type of elements stored in a set?
a) Ordered and unique
b) Unordered and unique
c) Ordered and duplicate allowed
d) Unordered and duplicate allowed
19. Which of these is the correct way to iterate over dictionary
keys?
a) for key in dict:
b) for key in dict.keys():
c) Both a and b
d) for key in dict.values():
20. How do you get the number of elements in a list called
'numbers'?
a) count(numbers)
b) len(numbers)
c) numbers.length()
d) numbers.count()
21. What will the output be:
d = {'a':1, 'b':2}
print(d['c'])
a) None
b) KeyError
c) 0
d) 'c'
22. Which method adds elements from another list to the end of a
list?
a) append()
b) extend()
c) add()
d) insert()
23. Which is a valid way to create a list of numbers from 0 to 4?
a) list(range(5))
b) range(0,5)
c) [0:5]
d) (0..4)
24. What does the function sorted() do?
a) Sorts a list and modifies it
b) Returns a sorted list without modifying the original
c) Reverses a list
d) None of the above
25. Which of the following is NOT a valid Python data structure?
a) List
b) Tuple
c) Array
d) Set
Section 2: Fill in the Blanks
26. A collection of unordered unique elements is called a ______.
27. A ______ stores key-value pairs.
28. The method used to add an item to the end of a list is ______.
29. To get all keys of a dictionary, we use the ______() method.
30. The function ______() is used to remove duplicates from a
list.
31. Elements in a tuple are ______ (mutable/immutable).
32. A list is ______ (mutable/immutable).
33. The index of the first element in a list is ______.
34. To remove an element from a set, we use the ______
method.
35. The 'pop()' method in dictionaries removes and returns the
______.
36. The method to clear all items in a dictionary is ______().
37. To add multiple elements to a set, we use the ______()
method.
38. The data type of 'None' in Python is ______.
39. To check if a key exists in a dictionary, we use the ______
operator.
40. To convert a list to a set, we use ______().
41. The method to get all values from a dictionary is ______().
42. A ______ is an ordered collection of elements.
43. The difference between a list and a tuple is ______.
44. The built-in function to find length of any collection is
______().
45. Sets do not support ______ operations like indexing.
Section 3: True/False
51. A dictionary stores data in key-value pairs. (True/False)
52. Lists are immutable in Python. (True/False)
53. Sets are unordered collections of unique elements.
(True/False)
54. Tuples can be modified after creation. (True/False)
55. The 'pop()' method removes and returns a random element
from a set. (True/False)
56. The 'update()' method can add multiple items to a dictionary.
(True/False)
57. Python dictionaries are ordered in Python 3.7 and later
versions. (True/False)
58. You can use indexing to access elements in a set.
(True/False)
59. Lists can contain duplicate elements. (True/False)
60. The 'clear()' method deletes all elements from a list.
(True/False)
61. You can convert a list to a set to remove duplicates.
(True/False)
62. The keys in a dictionary must be immutable. (True/False)
63. A tuple can contain elements of different data types.
(True/False)
64. Sets support mathematical operations like union and
intersection. (True/False)
65. The length of a dictionary is the number of keys it contains.
(True/False)
Section 4: Assertion and Reasoning
66. Assertion (A): Lists are mutable.
Reason (R): Tuples are immutable.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
67. Assertion (A): Sets allow duplicate elements.
Reason (R): Sets store unique elements only.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
68. Assertion (A): The 'pop()' method removes a random item
from a set.
Reason (R): Sets are unordered collections.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
69. Assertion (A): Dictionary keys must be immutable.
Reason (R): Mutable types can change and affect the dictionary.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
70. Assertion (A): Lists can contain duplicate elements.
Reason (R): Sets do not allow duplicates.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
71. Assertion (A): The 'update()' method can be used to add
elements to a dictionary.
Reason (R): The 'append()' method is used for lists.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
72. Assertion (A): Sets are ordered collections.
Reason (R): Lists preserve order of elements.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
73. Assertion (A): The 'clear()' method removes all elements from
a set.
Reason (R): The 'remove()' method removes a specific element.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
74. Assertion (A): The 'keys()' method returns all keys of a
dictionary.
Reason (R): The 'values()' method returns all values.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
75. Assertion (A): You can add items to a tuple.
Reason (R): Tuples are immutable.
a) Both A and R are true and R explains A
b) Both A and R are true but R does not explain A
c) A is true but R is false
d) A is false but R is true
Section 5: Short Answer Questions (2 marks)
76. What is a dictionary in Python?
77. How do you create an empty set?
78. How can you add an element to a list?
79. What method is used to remove a key from a dictionary?
80. How do you convert a list to a set?
81. Explain the difference between list and tuple.
82. How do you check if a key exists in a dictionary?
83. What is the difference between remove() and discard()
methods in a set?
84. How do you get the length of a list?
85. What is the difference between pop() in list and dictionary?
Section 6: Short Answer Questions (3 marks)
86. Write a Python program to create a dictionary and print all
keys.
87. Write a program to add elements to a set and remove an
element.
88. Explain how to remove duplicates from a list.
89. Write a program to iterate over a dictionary and print key-
value pairs.
90. What are the differences between lists, tuples, sets, and
dictionaries?
91. How do you handle key errors in dictionaries?
92. Write a Python program to merge two dictionaries.
93. Explain the concept of mutable and immutable types with
examples.
94. Write a program to check if a value exists in a list.
95. How do you sort a list of numbers in Python?
Section 7: Long Answer Questions (4 marks)
96. Explain Python data structures with examples.
97. Write a program to count the frequency of each element in a
list.
98. Describe how to use sets for mathematical operations like
union and intersection.
99. Write a Python program to sort a dictionary by its values.
100. Explain the difference between shallow and deep copy with
examples.
Section 8: Long Answer Questions (5 marks)
101. Write a Python program to implement CRUD operations on a
dictionary.
102. Explain the use of list comprehension with examples related
to data handling.
103. Write a Python program to find common elements between
two lists.
104. Discuss the advantages and disadvantages of different
Python data structures.
105. Write a program to remove duplicate elements from a list
without using set().
Answer Key
Section 1: Multiple Choice Questions (MCQs)
1. b
2. c
3. c
4. b
5. b
6. c
7. b
8. c
9. c
10. b
11. a
12. a
13. b
14. b
15. a
16. b
17. c
18. b
19. c
20. b
21. b
22. b
23. a
24. b
25. c
Section 2: Fill in the Blanks
26. set
27. dictionary
28. append
29. keys
30. set
31. immutable
32. mutable
33. 0
34. remove
35. value
36. clear
37. update
38. NoneType
39. in
40. set
41. values
42. list
43. mutability
44. len
45. indexing
Section 3: True/False
51. True
52. False
53. True
54. False
55. True
56. True
57. True
58. False
59. True
60. False
61. True
62. True
63. True
64. True
65. True
Section 4: Assertion and Reasoning
66. a
67. d
68. a
69. a
70. a
71. a
72. d
73. a
74. a
75. d
Section 5: Short Answer Questions (2 marks)
76. A dictionary is a collection of key-value pairs.
77. Using set() function, e.g. s = set()
78. Use list.append(element) to add element.
79. Use pop(key) method to remove a key from a dictionary.
80. Use set(list) to convert list to set.
81. Lists are mutable, tuples are immutable.
82. Use 'in' operator: if key in dict:
83. remove() raises error if element not found; discard() does not.
84. Use len(list) to get length.
85. pop() in list removes by index, in dict removes by key.
Section 6: Short Answer Questions (3 marks)
86. Create dictionary: d = {'a':1, 'b':2}; print(d.keys())
87. s = set(); s.add(1); s.add(2); s.remove(1)
88. Convert list to set and back to list: list(set(lst))
89. for k,v in dict.items(): print(k, v)
90. Lists mutable, tuples immutable, sets unique unordered, dict key-value pairs.
91. Use try-except for KeyError.
92. d1.update(d2) merges two dictionaries.
93. Mutable: list; Immutable: tuple, string.
94. if value in list: print('Exists')
95. lst.sort() or sorted(lst)
Section 7: Long Answer Questions (4 marks)
96. Lists, tuples, sets, dictionaries - basic data structures in Python.
97. Use dictionary to count frequencies in list.
98. Use union(), intersection() on sets for mathematical operations.
99. Use sorted(dict.items(), key=lambda x:x) to sort by values.
100. Shallow copy copies references, deep copy copies objects recursively.
Section 8: Long Answer Questions (5 marks)
101. CRUD on dict: add, read, update, delete using keys and dict methods.
102. List comprehension: [x*2 for x in list] for data manipulation.
103. Use set intersection: set(list1) & set(list2).
104. Lists flexible, tuples immutable, sets unique unordered, dict key-value.
105. Loop over list, add unseen elements to new list to remove duplicates.