Page 227 - Information_Practice_Fliipbook_Class11
P. 227
B. State whether the following statements are True or False:
1. A dictionary can have two different keys with same value. __________
2. A tuple can be used as key in a dictionary. __________
3. The value associated with a key in a key-value pair of a dictionary cannot be modified. __________
4. Given a dictionary, its values can be accessed using keys as indexes. __________
5. The method sorted() is used to sort the keys of a dictionary in ascending or descending order. __________
C. Fill in the blanks.
1. The elements of a dictionary are enclosed in ____________ brackets.
2. Every dictionary item 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:
rollnoMarksDict = {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 program to find the number of occurrences of each character in a given string in the form of a dictionary.
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
Python Dictionaries 213

