9 Dictionary9
9 Dictionary9
syllabus
2022-23
Chapter 9
Dictionary
Output
('before del', {'Class': 11, 'Subject': 'Informatics Practices'})
('after item delete', {'Subject': 'Informatics Practices'})
('after dictionary delete', <type 'dict'>)
Dictionary
pop() method is used to remove a particular item
in a dictionary. clear() method is used to remove
all elements from the dictionary.
e.g.
dict = {'Subject': 'Informatics Practices', 'Class': 11}
print('before del', dict)
dict.pop('Class')
print('after item delete', dict)
dict.clear()
print('after clear', dict)
Output
('before del', {'Class': 11, 'Subject': 'Informatics Practices'})
('after item delete', {'Subject': 'Informatics Practices'})
('after clear', {})
Dictionary
Built-in Dictionary Functions
Questions.
1. Create dictionary to store 4 student details
with rollno,name,age field.Search student in
list.
2. Create dictionary for month and noofdays for
a year. User is asked to enter month name
and system will show no of days of that
month.