Page 390 - Computer Science Class 11 With Functions
P. 390
Assessment
A. Multiple Choice questions
1. Which of the following creates a dictionary?
a. dict1 = {'a', 1:'b',2:'c',30:'d',100}
b. dict2 = {'a',1:'b',2:'c',30:'d',100}
c. dict3 = {'a':1,'b':2,'c':30,'d':100}
d. dict4 = ['a':1,'b':2,'c':30,'d':100]
2. Which of the following data types cannot be used as keys in a dictionary?
a. Tuple b. String c. Integer d. List
3. The statement d.clear() will ___________________________
a. delete all key-value pairs of the dictionary d
b. delete the dictionary d
c. deletes only last key-value pair of dictionary d
d. result in an error
4. What will be the output produced on the execution of the following code snippet?
dictItems = {'Mug':400, 'Book':550, 'Watch':950}
print(sorted(dictItems))
a. ['Book', 'Mug', 'Watch']
b. {'Book': 550, 'Mug': 400, 'Watch': 950}
c. {'Mug': 400, 'Book': 550, 'Watch': 950}
d. None of these
5. Which of the following can be the possible output produced on the execution of the following code snippet?
colours = {"red", "green", "blue", "Yellow"}
code = 0
cDict = {}
print( cDict.fromkeys(colours, code) )
a. {'Yellow': '0', 'red': '1', 'blue': '2', 'green': '3'}
b. {'Yellow': 0, 'red': 0, 'blue': 0, 'green': 0}
c. {'Yellow': 1, 'red': 2, 'blue': 3, 'green': 4}
d. Error
6. Consider the following dictionary:
subjects = {101:'English', 102:'Hindi', 103:'Maths'}
Which of the following pairs of expressions will yield the same output?
a. subjects.get('102') and subjects[102]
b. subjects.popItem(102) and subjects[102]
c. subjects.values() and subjects.items()
d. subjects[102] and subjects.get(102)
7. Which of the given statements will add a new key value pair to the dictionary d1 given below:
d1 = {"Netflix":300, "Prime":250, "Sony Liv": 100}
a. d1["Prime"]=190
b. d1["Disney Hotstar"]=175
c. abc=d1.get("Netflix")
d. d1.update({"Sony Liv":280})
388 Touchpad Computer Science-XI

