Page 443 - Computer Science V2.0 Class 11
P. 443
C. Fill in the blanks.
1. The elements of a dictionary are enclosed in _________ brackets.
2. Every item in the dictionary must have a unique _________ with its corresponding value.
3. To delete a key-value pair from a dictionary, _________ statement is used.
4. The function _________ is used to create an empty dictionary.
5. The _________ method returns a new copy of the dictionary.
D. Answer the following questions:
1. What is a dictionary in Python? Illustrate with the help of an example.
2. Is slicing applicable to dictionaries? Justify your answer.
3. Which type of objects can be used as keys in dictionaries?
4. Give any two ways of creating an empty dictionary.
5. Why is a dictionary termed as an unordered collection of key: value pairs?
6. Given a dictionary with key value pairs to be Roll no and marks of the student as follows:
rollnoMarks = {1:60,2:25,3:90,4:32,5:12,6:78}
Write a code segment to get the roll nos of the students securing 40 marks or above.
7. Write a function charCountDict(string) to find the number of occurrences of each character in a given string in the
form of a dictionary. Apply the function charCountDict(string) to a list entered by the user.
8. Write a program that accepts from a user the number of students in a class, followed by the names and marks of the
students in the class, stores them in a dictionary as key-value pairs, and displays the name of the student who has scored
maximum marks.
9. Write a program to do the following:
• Create a dictionary of month names and the number of days in a month.
• Displays the names of months having 31 days.
• Accepts a month name from a user and displays the corresponding number of days.
• Displays the names of months in alphabetical order.
10. Create a dictionary of employees with their Aadhar card numbers, names, and salaries. Write a menu driven program to
fetch the details of employees based on their Aadhar card number.
11. Write a program to do the following:
• Create a dictionary of employees id mapped to a list storing their name, department, and salary.
• Displays the id and name of employees having a salary greater than 50,000.
• Accepts the employee id from a user and displays the corresponding details of the employee.
• Displays the ids of employees in sorted order.
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): Dictionary is an unordered data type.
Reasoning (R): The key-value pairs in a dictionary are accessed using keys as indexes.
2. Assertion(A): Python does not allow modification of keys in a dictionary.
Reasoning (R): Keys are used to retrieve the corresponding key-value pairs in a dictionary.
Dictionaries 429

