Page 109 - tp_Modula_v2.0
P. 109
3. …………………… method is used to remove arbitrary element from the Python dictionary.
4. …………………… method is used to delete a specific element or entire dictionary.
D. Short answer type questions.
1. What is dictionary?
2. What do you mean by accessing a dictionary?
3. How will you update an element in a dictionary?
E. Long answer type questions.
1. How will you create a dictionary? Explain with an example.
2. Write any one difference between pop( ) and clear( ) method.
Critical Thinking
3. What is the use of get(key) method?
F. What will be the output of the following codes?
1. mydict={"name": "A", "class":"XII", "year":2022}
print(mydict)
mydict["stream"] = "Science"
print(mydict)
2. dict1={'Name': 'A', 'Rollno': 1}
print(dict1)
dict1['Rollno']=2
dict1['Marks']=[15, 47, 54]
print(dict1)
In the lab Technology Literacy
Write a program in Python to:
1. create a dictionary with 15 keys 0...14.
2. traverse a dictionary (dict = {1:'one', 2:'two', 3:'three', 4:'four'}) using a for loop.
Teacher's Corner
1. Discuss the concept of key-value pair with the help of examples with the students.
2. Do a walk-through of all the topics covered in this chapter.
Dictionary in Python 107

