Page 387 - Computer Science Class 11 With Functions
P. 387
14. What will be the output produced on execution of the following code snippet:
d = {'1':'One','2':'Two'}
for k,v in d.items():
z = k,v
print(type(z))
Ans. <class 'tuple'>
<class 'tuple'>
Assertion and Reasoning Based Questions
The following questions are assertion(A) and reasoning(R) based. Mark the correct choice as
a. Both A and R are true and R is the correct explanation of A
b. Both A and R are true and R is not the correct explanation of A
c. A is true but R is false
d. A is false but R is true
1. Assertion(A): The method pop() deletes the last key-value pair from a dictionary.
Reasoning(R): The method popitem() deletes a key-value pair from a dictionary.
2. Assertion(A): Dictionary is a mutable data type.
Reasoning(R): The keys in a dictionary are required to be unique.
Ans. 1. d 2. b
Case Based Questions
On the occasion of an interschool festival, Ruhaan has been assigned the task of maintaining the points tally. As he just
learnt about dictionaries, he wants to develop a program that will accept from a user the following data about the events
in which a school participates:
School Name - string
Event Name- string
Position - integer
A school can participate in any one of the following events: Quiz, Hackathon, Gaming, Coding, and Image Editing. The points
will be assigned according to the position as given below:
Position Value Points
1 10
2 5
3 3
Further, he would like to store and display the resulting data in the form of a dictionary:
School Name - string
Event Name- string
Points - integer
Help Ruhan develop a menu driven program.
Ans. events = ('Quiz', 'Hackathon', 'Gaming', 'Coding', 'Image Editing')
pointsTally = {}
def menu():
'''
Dictionaries 385

